Ben Lee trouble creating a new android project
Posts 1
Added by Ben Lee over 1 year ago

Hi. I've looked all over for similar problem but can't seem to find the answer so I'm hoping someone could help me.
I ran create-android-project.sh in mac terminal and it works fine. I run build_native.sh and there's no errors. Then I create a new android project in eclipse from existing source code (the directory that I created from the shell script) but I get a few errors.

In the androidmanifest.xml file, the line "android:icon="@drawable/icon">" it says no resource is found. That is simple enough to solve. I just copy the icon.png file into the res/drawable dir.

In the <ProjectName>.java file, these 3 lines have errors:
setContentView(R.layout.game_demo);
mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.game_gl_surfaceview);
mGLView.setTextField((EditText)findViewById(R.id.textField));

Right now, it can't find the R. But I noticed in the HelloWorld sample, it doesn't have the "import android.R" line. How do I fix this?

I assume if I just run that simple script, it would generate the HelloWorld sample code for me to start with, and there would be no compile problems. Did I miss a step or overlook something. Would appreciate any help.

BTW, I am using cocos2d-1.0.1-x-0.9.2. Thanks.

Minggo Zhang RE: trouble creating a new android project
Posts 1641
Added by Minggo Zhang over 1 year ago

Build the android project in eclipse, then the R.java will be generated.

令东 曾 RE: trouble creating a new android project
Posts 1
Added by 令东 曾 over 1 year ago

I occur the same problem while creating a project from exsisting source.

If you config your Enviroment with android-ndk-r7+android-sdk_r08-windows+jdk1.7, you will occur:
1. cannot compile prpjects when bash ./bulid_native.sh
2. the same problem with you, can't find the R.java and "android:icon="@drawable/icon">" error.

You should do this:
1. open cocos2d-1.0.1-x-0.9.1\cocos2dx\Android.mk, change
LOCAL_CFLAGS := -DUSE_FILE32API
to:
LOCAL_CFLAGS := -DUSE_FILE32API -DGL_GLEXT_PROTOTYPES=1

2. After creating your project with Eclipse, right click your project--properties--Java Compiler--select "Enable project specific settings" --select "Compiler compliance settings",set to"1.6"--Apply, that is all.

I think this will help you, I am so sorry with my poor English.

xie zhen RE: trouble creating a new android project
Posts 13
Added by xie zhen over 1 year ago

i have the same problem, i did all in this article "http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Chapter_1_-_How_to_Create_a_New_cocos2d-x_project_on_multi-platforms". but i can't find the var "game_demo" in R.layout, and the same of others. is it the version of android, i use android 2.1-update1(target: 3);

xie zhen RE: trouble creating a new android project
Posts 13
Added by xie zhen over 1 year ago

i'm sorry, before i build the project, i found there are some errors, so i import android.R to the file, so the errors appear, i remove "import android.R" the errors are solve.

Honghui Zhang RE: trouble creating a new android project
Posts 1
Added by Honghui Zhang over 1 year ago

That is some problem with create-android-project.sh, see Bug #866.

Before the bug be fixed,you can copy the lost file and dirs from HelloWorld project to make your target project work.

Moc Interactive RE: trouble creating a new android project
Posts 28
Added by Moc Interactive 9 months ago

Hi there ,

i'm having a similar problem , but only when i import a exter sdk in my android project.
actually im trying to integrate the Gree Social Platform with cocos2dx android , when i do this , the same error of the R.XXXXX compilation appear.

setContentView(R.layout.game_demo);

I'v clean and build , even restart the computer kkk , but the error 100% is in the import of SDK , somehow this import override the R compilation class.

Any Idea? i'v already post in Gree forum , but nothing.

Thanks

Honghui Zhang wrote:

That is some problem with create-android-project.sh, see Bug #866.

Before the bug be fixed,you can copy the lost file and dirs from HelloWorld project to make your target project work.


(1-6/6)