Yehsam
March 21, 2013, 6:50am
#1
Hi
I download the least version cocos2d-2.1rc0-x-2.1.2.zip
and use create-android-project.sh to create Android Project
And use ./build_native.sh to compile the code (Did not add any .cpp)
It will show error :
/Users/xxx/AndroidSDK/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/…/lib/gcc/arm-linux-androideabi/4.6/…/…/…/…/arm-linux-androideabi/bin/ld: ./obj/local/armeabi/curl.a(dso_dlfcn.o): in function dlfcn_pathbyaddr:(.text.dlfcn_pathbyaddr+0xe): error: undefined reference to ‘dladdr’
Is this a bug?
I use cocos2d-2.1beta3-x-2.1.1.zip is correct
Thanks
I have just tested it.
There is not problem.
What’s the NDK version you used?
Mine is r8d.
Yehsam
March 21, 2013, 7:48am
#3
My NDK version is r8d,too!
Are you create new android porject?
If i use sample TestCpp to build native is correct.
But if i create new project use ./create-android-project.sh will compile error
And this error will appear when compile almost done
Error message:
Compile thumb : chipmunk_static <= cpSweep1D.c
Compile thumb : chipmunk_static <= cpVect.c
StaticLibrary : libchipmunk.a
StaticLibrary : libextension.a
SharedLibrary : libgame.so
/Users/xxx/AndroidSDK/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/…/lib/gcc/arm-linux-androideabi/4.6/…/…/…/…/arm-linux-androideabi/bin/ld: ./obj/local/armeabi/curl.a(dso_dlfcn.o): in function dlfcn_pathbyaddr:(.text.dlfcn_pathbyaddr+0xe): error: undefined reference to ‘dladdr’
Yep, i created a new project.
walzer
March 21, 2013, 7:57am
#5
Wei-Sung Yeh, please describe your steps so that we can reproduce your problem. e.g, the command line you inputted to create your new project.
Yehsam
March 21, 2013, 8:03am
#6
ok
into cocos2d-2.1rc0-x-2.1.2 directory
./create-android-project.sh
package:com.test.test
input target id: 3 (id: 3 or “android-7”)
project name:test
cd test/proj.android/
./build_native.sh
Thanks a lot
Yehsam
March 21, 2013, 8:15am
#7
I found the problem
if i choice Target id (5 or “android-8”)
it will correct @@"
The lowest version cocos2d-x supports is android-8.
Because android supports opengl es 2.0 since android-8.
i have similar problems too; but not at that locations;
Mine is that the generated MainActivity is not working and the org.cocos2dx.lib is empty;
After fixing these, it show this error when running the app.
06-10 03:07:51.570: W/apk path(27636): /data/app/demo.hello-2.apk
06-10 03:07:51.570: W/dalvikvm(27636): No implementation found for native Lorg/cocos2dx/lib/Cocos2dxActivity;.nativeSetPaths:(Ljava/lang/String;)V
06-10 03:07:51.570: D/AndroidRuntime(27636): Shutting down VM
06-10 03:07:51.570: W/dalvikvm(27636): threadid=1: thread exiting with uncaught exception (group=0x4129c2a0)
06-10 03:07:51.570: E/AndroidRuntime(27636): FATAL EXCEPTION: main
06-10 03:07:51.570: E/AndroidRuntime(27636): java.lang.UnsatisfiedLinkError: Native method not found: org.cocos2dx.lib.Cocos2dxActivity.nativeSetPaths:(Ljava/lang/String;)V
06-10 03:07:51.570: E/AndroidRuntime(27636): at org.cocos2dx.lib.Cocos2dxActivity.nativeSetPaths(Native Method)
06-10 03:07:51.570: E/AndroidRuntime(27636): at org.cocos2dx.lib.Cocos2dxActivity.setPackageName(Cocos2dxActivity.java:226)
06-10 03:07:51.570: E/AndroidRuntime(27636): at demo.hello.HelloCCX.onCreate(HelloCCX.java:49)
06-10 03:07:51.570: E/AndroidRuntime(27636): at android.app.Activity.performCreate(Activity.java:5206)
06-10 03:07:51.570: E/AndroidRuntime(27636): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-10 03:07:51.570: E/AndroidRuntime(27636): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
06-10 03:07:51.570: E/AndroidRuntime(27636): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
yes, I fixed the problems.
The main issues are:
missing the java codes needed by Android
Solution:
@
mkdir YourProject/proj.android/src/org/cocos2dx/lib/
cp cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dx*.java YourProject/proj.android/src/org/cocos2dx/lib/
@
Missing the Icon.png
Solution:
@
cp samples/Cpp/HelloCpp/proj.android/res/drawable-hdpi/icon.png YourProject/proj.android/res/drawable-hdpi/
@
Similar to other tutorials, we need to configure build_native.sh after it is created.
After run ‘build_native.sh’ and import to Eclipse, the Cocos2dx.apk can be run.
If you want to add some Cocos2dx code, need to modify the YourProject/jni/Android.mk.
Regards,
Ken