Which one to use, NDKr9d or NDKr10c? [SOLVED]

Hi,
I need a bit of guidance here.
I built a small game using NDK r10c, it compiles fine, but when I package it to apk and install it on the phone (Android 4 and android 5) it crashes on start up, I found that the issue is caused by some missing functions, check this post: [Need Help] Android app crash on launch

I the found that compiling with NDK r9d fixes the problem altogether, however I get the following warnings after the compilation is done:

The NDK version is not r10c or above. Your application may crash or freeze on Android L(5.0) when using BMFont and HttpClient. For More information: https://github.com/cocos2d/cocos2d-x/issues/9114 https://github.com/cocos2d/cocos2d-x/issues/9138 Your application may crash when using c++ 11 regular expression with NDK_TOOLCHAIN_VERSION 4.8*****

So my question is, how should I move forward given that with either NDK there are (or there may be) issues?

Thanks in advance for your advice.

I recently switched to ndk10e and encountered the same issue.

I finally solved this by targetting android-19 and not above because it seems there is a compatibility change starting at android sdk 20.
I haven’t tested my build on an android 5 device yet, but it would work correctly.

So how I fixed my issue after migrating to a recent ndk, is by using android 19

Thanks for your reply @dakiki.
I tried your approach on Android 4.4.4 and 5.0.2 and no problems at all, the issue went away.
I’ll leave it like that for now and hope they fix it in the future.
Many, many thanks for your advice.

Cheers

Glad to help, I’ve lost 8hours on this…
And based on what I’ve read, it’s not an issue related to cocos, it looks like it’s a very bad decision from google concerning android 5 which totally broke compatibility.
If you want to target older devices you have to use android sdk up to 19 (which should run on android 5 using some sort of compatibility mode, like windows does)… and if you want to use the newest features of android 5, you have to make another apk target sdk 22 or more. A shame if you want my opinion, but I guess we don’t have a choice

You are absolutely right, we don’t have a choice for now, read here https://code.google.com/p/android/issues/detail?id=73725.
I hope they implement that “compatibility library” they talk about.

Recommend:
v3.0-v3.2: NDK r9d
v3.3-v3.8: NDK r10c

1 Like

I even have NDK r10e working with V3.7

Why 10c and not 10e?
Is there something broken in NDK after 10c?
(I’d like to know if there is a critical issue after 10c since 10e is better supporting c++11/14 stuff)

Can you explain how you set up 3.7 with Android Studio ? I’ve been struggling with this - all the environment variables everything is fine. But when I try to run the basic template app (which is created by cocos new) on a device it keeps crashing with the message “Unfortunately libcocos2dx stopped working…”

I have:

  • NDK r10e
  • My apache ant is pointed to the one that came with the new cocos v2.3, not to a separate downloadable ANT file (that caused problems for me).
  • I downloaded the Android SDK only, not Android Studio or the one with Eclipse.

That’s all I know as far as how I got my new project working.
Hope that helps!

We have tested r10c completely, but not means that r10e is NG, maybe r10e is ok, I don’t know.

You can refer some threads like http://discuss.cocos2d-x.org/t/build-android-base-on-ndk-r10c/18543.

I can get a the app created by the template to compile and run on the device just by using the command line:

cocos run -s ./MyAppPath -p android

I haven’t been able to get it to run using android studio (it keeps trying to launch libcocos2dx) so there must be some config problem. Because it is trying to launch the lib, instead of the app.

I have:

NDK: r10e
Android Studio 1.3
Android SDK 22

I’ve only been using the command line. I don’t use Android Studio, sorry can’t help you there.

@dakiki can you explain how you targeted android-19?

Did you modify the android manifest file? Did you directly run using cocos command? If so can you please show the cocos run command you used?

My androidmanifest has this line:

< uses-sdk android:minSdkVersion=“9” android:targetSdkVersion=“19”/>

and you compile with cocos like that:

cocos compile -p android --ap android-19

2 Likes

Thank you.

Were you able to run the project in Android Studio? (cocos compile -p android --android-studio --ap android-19)

I didn’t try but I guess it should work.
I had so many issues with Eclipse when switching computers (sometimes using a Windows and sometimes using a MacOS) that I dropped IDE support for compiling and running for android (and since debugging is really a pain in… on android, there is no need for an IDE).

But that was when I created my project 2 years ago, so maybe I should give Studio a chance now, but I don’t really feel like I need it. I can debug from command line easily with ndk-gdb.

I got it to work in Android Studio. Just see the other thread from sonar learning. They made a video on how to.