I got a problem with the game building/running on Android 4.4 devices.
If I set target=android-21 or above in project.properties, i can build it successfully but the game crashes on Android 4.4 (it runs good on Android 5.0 or above). The crash was caused by:
dlopen failed: cannot locate symbol "rand" referenced by "libMyGame.so".
So I changed it totarget=android-19, now the build was not successful with link error:
...MyGame.cpp:97: error: undefined reference to "rand"
HOWEVER, if I build the project in debug mode (without “-m release”), it is all good no matter if it’s target=19 or target=24
BTW, I also tried NDK r11c. It is very similar but in the second scenario, the compile failed even earlier at CCConsole.cpp with all the function references to rand, srand, etc. And if I build it with target=android-19 without release mode, it also failed but the error is only the undefined reference to bzero in CCConsole.cpp.
I searched the forum and did not find a solution… Can someone please help?
OK, I cleared all the intermediate files and object files. It is working fine now with target=android-19. With android-24, the app still crashes on Android 4.4.4 though.
Yes, it was a rand problem, but targeting API 19 it’s ok for Android 5.1.1 on Nexus 5.
Actually I’m porting my game from v 3.7 to v3.11.1 and with v3.7 I was able to install on a Samsung GT-S5830C v2.3.6-GINGERBREAD. Now, I’m getting this:
@lfmn, Yes, targeting API 19 is OK for higher versions.
To be honest, I am very confused on the target-platform in cocos2dx. Although I can either specify the target-platform with arugments --ap=android-xx or set in project.properties under proj.android-studio/app directory, I don’t know exactly how much is affected by this. I mean, I can have different settings in the gradle script with targetSDK=24. So I am not very sure if the target-platform settings in cocos2dx only affects the build of library (libMyGame.so) and the gradle will take care of the build of application (the apk) or will it overrides the target in gradle. Maybe I just need to read more documentation about the build process of NDK development and/or the source code of the build scripts.
Nevertheless, back to the error you are facing, it looks like an error of dereferencing a nullptr. Maybe you can check the following:
Make sure libcocos2dcpp.so is under the libs folder in the APK file. If not, you may need to change the lib name in AndroidManifest or check if the library in libs folder under your proj.android directory (I assume you are using Android Studio)…
Check the logcat a few lines before the error you posted to see if there are any error messages like “cannot find xxx.png”, possible missing resources.
I’m very confused too with exactly same doubts. I’m using android studio and I realized that target of project.properties file is updated when I compile the project.
There is libcocos2dcpp.so file and I just see this messages: