Which API should I use?

Which API should I use?

I compiled the my game application with API 26 (Android 8.0.0).

This app working on “Galaxy S7 edge (Android 7.0)” but it crashed on “Galaxy S4 (Android 5.0.1)”.

“Clash of Clans and etc. apps where on Google Play Store” works perfectly in these devices. Which API they are using?

How can I compile my game application like they?



I’m using this app to check the targetAPI of the apps, but at Nov 2018 every app update (and new app) has to have at least targetAPI 26 -> see also Important TargetSDK and NDK changes in Android app publishing.

And you should understand the differences between targetSDK and minSDK. My minSDK is 19 (Android 4.4), so I’m sure the C++ code can’t use newer features. My targetSDK is 27 (Android 8.1), so I’m sure, the Java code is checked against it by lint while compile time.

Any other questions?



1- Which API levels should be installed in my sdk folder?

2- Currently only API 26 is installed in my sdk folder.

3- Which API level should I write when compiling on Cmd?



This is the targetSDK and 26 is fine.

I don’t know the used cmd of your build, because I just call in my proj.android folder the cmd ./gradlew build (on macOS).

And watching at the 3.17 sources (which is also in your proj.android folder) you can answer your question on your own.

It’s really hard for me to help you without any further information about your current setup. So I can only answer globally.

PS: Did you read and understand the links? Without minimal knowledge of Android builds, you can just copy’n’paste. This will lead to problems in the future, because as I mentioned above: at the end of 2018 you have to follow a new guideline for app updates.

1 Like


For example:


If I do as above…
Do I need to have all APIs installed on my computer up from API 15 to API 26?

PS: “Did you read and understand the links?” (Yes I did read and understand the links.)

1 Like


No, you don’t need all of them. The target is enough.

Okay, what does the logcat tell you on the Galaxy S4. If you have minSdk = 15, so your Java/Kotlin code must not call any Android API-calls above 15 without an API-if-clause (e.g):


If the crash is within the C++ code, you have a bigger problem. :wink: Just kidding. Sometime Samsung phones does have shitty Android. I know for sure that e.g. Samsung has a really bad Bluetooth implementation.

PS: Did you test it within an emulator with Android 5? Is there the same error? - The emulator is often x86, so you need to add this to your ABI, because cocos default is only armeabi-v7a.

1 Like



I do as above… But crash again on Galaxy S4.
Why? I tried for default cocos2dx app.



What does the logcat say? I need any error message to go further…

1 Like


It say “Unfortunately, TestGame has stopped!”

If you want I can send you my .apk?



Try also adding APP_PLATFORM := android-19 in your project\\proj.android\jni\Application.mk
Delete obj folder first and recompile, it should work.

1 Like


That’s not the logcat. That’s the alert dialog in the Android UI.

I need this, which is also visible in Android Studio.



I am using Atom Editor.



I will try.

So, Can I compile using API 19? Or I am is it just change the line in Android.mk?

Why should I delete the obj folder?



So you have to use the adb command line tool to show you logcat within the terminal.

1 Like


If his minSdkVersion == 15, the android-19 for the ndk build can break devices with Android API 15 to 18. The minSdkVersion has always to be the same (or higher) as the APP_PLATFORM in the Application.mk file.

1 Like


No dont change anything, just add that line in Application.mk

If you make changes in any .mk files then you should delete obj folder, so it will compile again.

But this is what is working for me, many post in stackoverflow will tell you the same.
If minSdkversion is less than 19 than we have to add this in Application.mk file.
I tested this in many devices, it will work for sure and made many games with such config no problem so far.

1 Like


I wouldn’t bet on that. But if you see on the documentation you will see, that between 15 and 19 aren’t new header files, but the you can’t see the underlaying static libraries and this way it could break your game.

To be sure, that it’s working, I won’t differ both settings.

PS: I wouldn’t trust SO, because often the accepted answer isn’t the right one. It’s just a hint in my opinion, but you shouldn’t fully trust it.

1 Like


I got your point BUT if i dont add that line then its crashing for below 19 devices (100%).

1 Like


His test devices aren’t below API 19 :wink: But they crash… The main issue is, that we don’t know his error message from the logcat.

1 Like


Well Yeah, thats may be different issue.