Forum > C++ > trouble creating a new android project

trouble creating a new android project

By hullabal00 Posted 2011-10-21 15:35 Comments 6
hullabal00
  • Posts: 1

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.

zhangxm
  • Posts: 2069
  • Location: Xiamen, China

#1 RE: 2011-10-22 05:53

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

znlingdong
  • Posts: 1

#2 RE: 2011-11-17 03:36

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

  1. 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.

pClass2
  • Posts: 16

#3 RE: 2011-11-22 22:53

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);

pClass2
  • Posts: 16

#4 RE: 2011-11-22 23:00

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
  • Posts: 1

#5 RE: 2011-11-22 23:11

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
  • Posts: 28

#6 RE: 2012-09-05 18:03

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.

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps