cocos2d-x v3.3 and NDK r10d

I’ve been trying to use NDK 10d with cocos2d-x v3.3.

I’ve done the necessary changes(there are 3 changes that I did on the whole after importing in eclipse) as talked in conclusions of http://www.cocos2d-x.org/news/307

But on running on my device it says ‘Unfortunately myproject has stopped’.
It is giving the log as following:
(NOTE: v3.3 is working fine with NDK r9d on my device)


01-07 23:09:16.950: D/jdwp(25477): sendBufferedRequest : len=0x35
01-07 23:09:16.962: D/dalvikvm(25477): open_cached_dex_file : /data/app/org.learn.ch3-2.apk /data/dalvik-cache/data@app@org.learn.ch3-2.apk@classes.dex
01-07 23:09:16.968: W/dalvikvm(25477): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/cocos2dx/cpp/AppActivity;
01-07 23:09:16.968: W/dalvikvm(25477): Class init failed in newInstance call (Lorg/cocos2dx/cpp/AppActivity;)
01-07 23:09:16.968: D/AndroidRuntime(25477): Shutting down VM
01-07 23:09:16.968: W/dalvikvm(25477): threadid=1: thread exiting with uncaught exception (group=0x41d099a8)
01-07 23:09:16.970: E/AndroidRuntime(25477): FATAL EXCEPTION: main
01-07 23:09:16.970: E/AndroidRuntime(25477): java.lang.UnsatisfiedLinkError: Couldn’t load compiler_rt_shared from loader dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/org.learn.ch3-2.apk”],nativeLibraryDirectories=[/data/app-lib/org.learn.ch3-2, /vendor/lib, /system/lib]]]: findLibrary returned null
01-07 23:09:16.970: E/AndroidRuntime(25477): at java.lang.Runtime.loadLibrary(Runtime.java:359)
01-07 23:09:16.970: E/AndroidRuntime(25477): at java.lang.System.loadLibrary(System.java:514)
01-07 23:09:16.970: E/AndroidRuntime(25477): at org.cocos2dx.cpp.AppActivity.(AppActivity.java:34)
01-07 23:09:16.970: E/AndroidRuntime(25477): at java.lang.Class.newInstanceImpl(Native Method)
01-07 23:09:16.970: E/AndroidRuntime(25477): at java.lang.Class.newInstance(Class.java:1319)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2223)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.app.ActivityThread.access$600(ActivityThread.java:156)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.os.Looper.loop(Looper.java:153)
01-07 23:09:16.970: E/AndroidRuntime(25477): at android.app.ActivityThread.main(ActivityThread.java:5299)
01-07 23:09:16.970: E/AndroidRuntime(25477): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 23:09:16.970: E/AndroidRuntime(25477): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 23:09:16.970: E/AndroidRuntime(25477): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
01-07 23:09:16.970: E/AndroidRuntime(25477): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-07 23:09:16.970: E/AndroidRuntime(25477): at dalvik.system.NativeStart.main(Native Method)


I want to use NDK r10d so that I could check ARM-DS5 for debugging on eclipse

Thanks

Debugging sounds fantistic. I just want to use v3.3 at all but the zip is much bigger and I’ll need to update everything. By then it’ll be too late to say, “waaa! my apk is still 15Mb!!”

Has the programmer’s guide not got a page on setting up v3.3 yet?

Ah thank you, that eases the upgrade pain for me.

One thing I forgot to mention that…
I said that I did 3 changes, but actually I did 2 because in v3.3 the return type from long int was already changed to ssize which is the correct one…

This is I think NDK r10 bug … Just read on http://www.cocos2d-x.org/news/307
They have suggested the ways… but I am not sure why isn’t it working after doing those changes…

And

I think it hasn’t talked abt v3.3 and NDK r10 together and infact there isn’t worth abt mentioning fixing this bug in the guide because this is not cocos2dx problem but NDK’s

Has no one encountered such an error ?

Sorry, I was able to use ndk r10d with cocos2d-x 3.3 out of the box. I am using Lua und cocos code ide.

My setup is a bit different so I don’t if it’s the same issue I saw. I use Xcode for C++ programming, then “cocos” command through terminal to make android builds. I upgraded NDK and generated a new project and everything was compiling and running correctly, then I wanted to add an Android feature that is new in KitKat so I changed the targetSDK in the manifest to 21 (since Lollipop is out I figured why not) AND I updated the project build target “android update project -p . -t ID” to Lollipop, and suddenly I was getting your error “Unfortunately…”. I had made some other changes at the same time so it took me a while to hunt down that the issue was the 2nd step of upgrading the project build target; apparently going to 20 or above breaks some compatibility with something in the runtime that is not caught by the compiler. I downgraded the build target to 19 (KitKat) and problem solved. Luckily the feature I needed was in API 19, and the app still runs fine on older versions of the OS as well (tested on a G Phone running 2.3.6).

Hope this helps someone.

sorry to bump old thread.
have you solved this problem ?
or you just back to r9d ?

i just tried cocos2d-x 3.3 today, and got the same problem.

i created new project, build it with “cocos run -s Test3 -p android”. and it failed.
try to import the project to eclipse -> success. run on device -> crash with almost same logcat, except, mine is

02-05 17:45:22.746: E/AndroidRuntime(16298): java.lang.UnsatisfiedLinkError: Couldn’t load cocos2dcpp from loader dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.MyCompany.Test3-1.apk”],nativeLibraryDirectories=[/data/app-lib/com.MyCompany.Test3-1, /vendor/lib, /system/lib, /system/lib/arm]]]: findLibrary returned null

thank you.

The logs says it can’t find the cocos2dcpp library. Could you check under proj.android/libs/[compiled architecture]/ that you have a libcocos2dcpp.so file? Otherwise, what do you have there?

What does the ndk-build result says? (I don’t know if cocos command show the output, as I don’t use cocos command).

nothing there, i checked the proj.android/libs/armeabi/ and nothing there.

try to run in terminal “cocos run -s Test3 -p android” and the result is

Running command: compile
Building mode: debug
Android platform not specified, searching a default one…
running: ‘/Users/rahadiankumang/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools/android update project -t android-20 -p /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android’

Updated project.properties
Updated local.properties
Updated file /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/proguard-project.txt
Android platform not specified, searching a default one…
running: ‘/Users/rahadiankumang/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools/android update lib-project -p /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/…/cocos2d/cocos/platform/android/java -t android-20’

Updated project.properties
Updated local.properties
Updated file /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/…/cocos2d/cocos/platform/android/java/proguard-project.txt
building native
NDK build mode: debug
NDK_TOOLCHAIN_VERSION: 4.9
running: ‘/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/ndk-build -C /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android -j4 NDK_MODULE_PATH=/Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/…/cocos2d:/Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/…/cocos2d/cocos:/Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/…/cocos2d/external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1’

Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml
make: Entering directory /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android' [armeabi] Compile++ thumb: cocostudio_static <= WidgetReader.cpp [armeabi] Compile++ thumb: cocostudio_static <= FlatBuffersSerialize.cpp [armeabi] Compile++ thumb: cocostudio_static <= WidgetCallBackHandlerProtocol.cpp [armeabi] Compile++ thumb: cocos_ui_static <= UILayoutComponent.cpp arm-linux-androideabi-g++: error trying to exec '/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/as': execv: Exec format error make: *** [obj/local/armeabi/objs-debug/cocos_ui_static/UILayoutComponent.o] Error 1 make: *** Waiting for unfinished jobs.... arm-linux-androideabi-g++: error trying to exec '/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/as': execv: Exec format error make: *** [obj/local/armeabi/objs-debug/cocostudio_static/WidgetCallBackHandlerProtocol.o] Error 1 arm-linux-androideabi-g++: error trying to exec '/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/as': execv: Exec format error make: *** [obj/local/armeabi/objs-debug/cocostudio_static/WidgetReader/WidgetReader.o] Error 1 /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/../cocos2d/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp: In member function 'std::string cocostudio::FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const string&, const string&)': /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/../cocos2d/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp:153:93: warning: 'virtual unsigned char* cocos2d::FileUtils::getFileData(const string&, const char*, ssize_t*)' is deprecated (declared at /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/../cocos2d/cocos/./platform/CCFileUtils.h:101) [-Wdeprecated-declarations] std::string content =(char*)FileUtils::getInstance()->getFileData(inFullpath, "r", &size); ^ /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/../cocos2d/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp: In member function 'flatbuffers::FlatBufferBuilder* cocostudio::FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulator(const string&)': /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/../cocos2d/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp:974:93: warning: 'virtual unsigned char* cocos2d::FileUtils::getFileData(const string&, const char*, ssize_t*)' is deprecated (declared at /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android/../cocos2d/cocos/./platform/CCFileUtils.h:101) [-Wdeprecated-declarations] std::string content =(char*)FileUtils::getInstance()->getFileData(inFullpath, "r", &size); ^ At global scope: cc1plus: warning: unrecognized command line option "-Wno-extern-c-compat" cc1plus: warning: unrecognized command line option "-Wno-extern-c-compat" arm-linux-androideabi-g++: error trying to exec '/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/as': execv: Exec format error make: *** [obj/local/armeabi/objs-debug/cocostudio_static/FlatBuffersSerialize.o] Error 1 make: Leaving directory/Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android’
Ndk build failed!

try to execute the build_native.py and failed too. the result here :

We will remove this script next version,you should use cocos console to build android project.

The Selected NDK toolchain version was 4.9 !
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml
make: Entering directory /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android' [armeabi] Compile++ thumb: cocos2dcpp_shared <= AppDelegate.cpp [armeabi] Compile++ thumb: cocos2dcpp_shared <= HelloWorldScene.cpp [armeabi] Compile++ thumb: cocos2dcpp_shared <= main.cpp [armeabi] StaticLibrary : libcocos2d.a /Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ar: line 1: ../../bin/arm-linux-androideabi-ar: No such file or directory make: *** [obj/local/armeabi/libcocos2d.a] Error 127 make: *** Waiting for unfinished jobs.... arm-linux-androideabi-g++: error trying to exec '/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/as': execv: Exec format error make: *** [obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/AppDelegate.o] Error 1 arm-linux-androideabi-g++: error trying to exec '/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/as': execv: Exec format error make: *** [obj/local/armeabi/objs-debug/cocos2dcpp_shared/hellocpp/main.o] Error 1 arm-linux-androideabi-g++: error trying to exec '/Users/rahadiankumang/Documents/GITS/Cocos2d-x/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/as': execv: Exec format error make: *** [obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/HelloWorldScene.o] Error 1 make: Leaving directory/Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android’
Traceback (most recent call last):
File “./build_native.py”, line 149, in
build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
File “./build_native.py”, line 134, in build
do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
File “./build_native.py”, line 70, in do_build
raise Exception(“Build dynamic library for project [ " + app_android_root + " ] fails!”)
Exception: Build dynamic library for project [ /Users/rahadiankumang/Documents/GITS/Cocos2dX/Test3/proj.android ] fails!

There are quite a lot of errors during cocos2d and the code in Classes compilation. Unfortunately, I can’t help you much, as I don’t really know what causes that.

Perhaps @slackmoehrle will have a clue?

Wow, umm this is a long list of errors :smile:

So 3.3? and on OS X?

What paths were added to .bash_profile when you ran setup.py

Can you compile cpp-tests? I’d think no given the errors that I see

We have instructions here: http://cocos2d-x.org/programmersguide/B/

Can you make it through this and see how it compares with your current setup?

What i did is simply change the ndk to r9d and everything seems fine now.

I tried to create new project, compile it with “cocos run -p android -j 4” and it went successfully. Had some warnings but no error.

So i guess the r10d is the problem ?

Maybe, but I don’t remember having very great difficulty in using NDK r10d. There were a couple of minor changes perhaps, as described elsewhere. It would be terrific if we could all work from the same sheet on this :slight_smile: Seriously considering doing all my coding in Android Studio for this effect. I guess iPhone programmers don’t have such diversity hang ups, but at £500 for a phone, I can’t afford that.

@kumangkumeng, you have to run source /Users/xxxxx/.bash_profile after updating the NDK_ROOT

I am using NDK r9d and still getting this error. Project was cleaned with ./build_native.py -n clean, but still this error persists:

5 errors generated.
make: *** [obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/AppDelegate.o] Error 1
make: Leaving directory `/Users/itzo/Documents/Android_Apps/DiamondSlots/DiamondSlot1.2/TEST/proj.android'
Traceback (most recent call last):
  File "./build_native.py", line 159, in <module>
    build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
  File "./build_native.py", line 146, in build
    do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
  File "./build_native.py", line 82, in do_build
    raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
Exception: Build dynamic library for project [ /Users/itzo/Documents/Android_Apps/DiamondSlots/DiamondSlot1.2/TEST/proj.android ] fails!

Please advice!