Cocos2d-x v3.13 and sdk/ndk versions

Hi,

Thank you for explanation. Does not mean that I can not create one app which will run on all Android 2.3.3+ devices?

I would like to have my app on as many as possible Android devices.
cocos2dx support Android 2.3.3+ (== SDK API 10)

Is there any point to use newer sdk api than 10 for cocos2dx game?
If no I think that we should use always SDK API 10 to be able to run on Android 2.3.3+

The same is about NDK. I think that we should always fix to one version.
Which ndk version do you use for developing/testing?
Which ndk version was used to build external libs (curl etc)?

I believe that we should always use one sdk/ndk configuration for cocos2dx release.

Which NDK version do you recommend for v3.13 (for v3.12 ndk12d does not work)?
android-ndk-r11c, android-ndk-r12b or some other?

Regards,
CHP

I think facebook and Google Play Services now requiring API 15+, there is now really no case to support 2.3.3+ - it’s ok to have 4.+. So I would recommend to use 19 or 22 API :slight_smile:

So 22 or 20?

If you are using Android Studio, do this:

In your gradle files, set the compile SDK version, the min SDK version, and target SDK version as you want. You can use ANY version that you want to use. I prefer to use the latest 23 or 24 for compile SDK and 22 for target SDK to not trigger Android 6 permissions, and I use min SDK as 14 as our app can’t run well on very old devices with very low power GPUs. But you can use any versions you want without worrying about any NDK related build issues or crashes.

Now comes the important part about NDK. Both cocos compile and NDK build ignore all these settings in your gradle file, instead they read the API version set in project.properties files. Set that as the minimum version you want to support, but at least version 13. This will not effect the Java build in Android Studio, this is only for NDK build.

Important: Check in your android studio sdk manager that Android SDK for BOTH your gradle compile sdk version and the project.properties sdk version is installed. Otherwise cocos compile command will try to use any version it can find, and also update your project.properties file. (As @zhangxm said, this behavior of cocos compile to search for any other available SDK will be changed in next release.).

If you are using Eclipse: I can’t help as I don’t know what effect changing project.properties will have on Java Android build with Eclipse.

This is only based on what I found out with my testing, please let me know if I am wrong or I missed something :slight_smile:

(This is with NDK r12b and Cocos2dx 3.13)

3 Likes

Thank you all for replies!

I looked in the documentation but I am still confused.

There are three entities

  • min sdk version - this api level is used at run time by android.

  • target sdk version - this api level is used at run time by android,
    android uses this setting to determine whether to enable any compatibility behaviors.

  • compile sdk version - this api level is used at compile time by cocos console,
    this api level is set by --ap android-xx.
    As I understand If I do not use super new api in the code or use runtime checks, then I expect backward compatibility with an earlier version of android.

I use a standard Hello World project. @zhangxm said that android ndk break compatibility since api 21, ok, so I use the sdk 19 and I do not understand why I should use the sdk 16 to be sure of the compatibility with 4.0.1.

Maybe the problem is that I did not have the min sdk version is installed
or is it a random ndk r12b error as @energyy said.

I will test it again this weekend.

I also think that now the actual min sdk version is 16.

@schngrg Do you test it on real 4.0.1 device or something like that?

Ok, now I installed the min sdk version. It is 16 in my case.

v3.13.1 + compile sdk 19 + ndk r12b

  • Ok on Galaxy S7 (6.0.1), Galaxy S6 (5.1.1), Galaxy Note 4 (4.4.4), Galaxy Tab 3 (4.1.1).

v3.13.1 + compile sdk 21 + ndk r12b

  • Ok on Galaxy S7 (6.0.1), Galaxy S6 (5.1.1), Galaxy Note 4 (4.4.4).
  • Crash on Galaxy Tab 3 (4.1.1).

v3.13.1 + compile sdk 24 + ndk r12b

  • Ok on Galaxy S7 (6.0.1), Galaxy S6 (5.1.1).
  • Crash on Galaxy Note 4 (4.4.4), Galaxy Tab 3 (4.1.1).

I used eclipse.

1 Like

The API level of 4.0.1 is 16. And i am not sure if you used API 17+ functions in Java codes, so i suggest you using API 16. There will have compiling error if you use API 17+ Java functions.

I found NDK break compatibility since 21, but i am not sure if 17 break any compatibility though i haven’t found anything.

Yea… Now I understand your idea. Thank you. :sunny:

So, to summarize, assuming a new game with cocos2D-X v3.13.1 (that may even use some SDKBOX plugins) our AndroidManifest.xml should have:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="24" />

and, assuming we’re using ndk12b, we should compile it with:

cocos compile -p android --ap android-19

Am I correct? :smile:

You can use a different version if you want.
And if you can test it.

Theoretically, yes . But I tested with targetSdkVersion = 19.
I will test target 24 next week.

Yes, you are correct , you should compile with the app platform 19.

Sorry for the double post . I am writing on a tablet.

Hi

My game works on all devices I own despite the sdk version I use so can’t test here :frowning: But I’ve seen with google analytics that there are some devices whose execution time is 1 second, which resembles a crash to mee, that’s what I’m trying to minimize.

About targetSdkVersion, as API document posted before states that:

To maintain your application along with each Android release, you should increase the value of this attribute to match the latest API level, then thoroughly test your application on the corresponding platform version.

I check my game works with android 6.0 before release (moto g 2014 with stock rom). Been using targetSDKVersion=23 until recent update, and, as wrote before, I have had no problems I could detect until now (my game is really simple though).

Regards

I said ‘theoretically’, because if believe the documents it works fine.
But according to the documents the compiling versions > 19 work fine too.

I can not help with google analytics.
Can you provide any more information on these devices?

Ok, I am writing on my laptop today.

I would like to clarify that meant that I had read these documents, but I prefer to test.

Also, I saw a crash on a very low performance devices. Maybe this is your case.

Hi

No worries, it is OK if you keep using your tablet :wink:

Yeah, testing seems to be only chance to get real results. I’m starting to have feeling that Android is such a big monster, with thousands of different devices and some with buggy drivers that it’s almost impossible to have it working on all devices.

Sadly, google analytics “hints” (just 1 second runtime) that it crashes on some high end devices, mostly from samsung, like S6 edge or S7. Odd enough, I’ve other players with same device that have been playing for almost an hour. Maybe it’s due the phone version (S6 for example have SM-G9200, SM-G920FD, SM-G920A SM-G920F, …) but not sure about this, just my thoughts.

1 Like

Try to use Crashalytics. You will get more accurate and detailed crash details for both Java and NDK/C++. Analytics only reports Java crashes and even there the stack trace is usually missing.

1 Like

@schngrg any hint on how to implement Crashalytics? It’s not listed in SDKBOX (only ganalytics, apteligent and flurry analytics there).

Thanks

You will have follow Crashalytics documentation. It doesn’t need any significant changes in code, only a few lines.

Huh… interesting. Thanks for the info.

I am facing crash issue in Android 4.4 device due to unsatisfied link error at Cocos2dxActivity.java System.loadLibrary(libName) method.

TARGET SDK VERSION 25
Min Sdk Version 14
Compile sdk version 25
Cocos2dx Version : cocos2d-x-3.15
NDK Version : 15.1.4119039
Guide me to solve this issue @zhangxm @slackmoehrle @walzer @smitpatel88