Hey guys,
I have a problem. I’m making an android game. I builded my cocos2dx project for android using as target android-22… But, the application crashes with the error:
I searched on the forums and found that you should build your project with android-20 or less as target if you want to support older devices.
This is what I did. I changed the target to android-19 in project.properties (for my project & for cocos). But when I try to compile the project I get the following errors:
This might be related to the problems a lot of people have with AndroidNDK. Depending on what version you have (and the constellation of the stars), your ndk support or does not support rand.
And atof seems to be even worse, since that doesn’t seem to be supported at all. Eventually I will need to search for a solution myself… Havn’t tried out strtof yet though.
I have a similar issue as well.
I initially compiled my project for android 22 and it worked fine.
Now that i want to extend the app to even lower devices I’ve changed the target to 19 and I’m getting this
[...]
[armeabi] SharedLibrary : libcocos2dcpp.so
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./base/CCConsole.cpp:737: error: undefined reference to 'srand'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./base/CCConsole.cpp:738: error: undefined reference to 'rand'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./base/CCConsole.cpp:765: error: undefined reference to 'srand'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./base/CCConsole.cpp:766: error: undefined reference to 'rand'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./base/ccUtils.cpp:205: error: undefined reference to 'atof'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./base/ccRandom.h:117: error: undefined reference to 'rand'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./2d/CCActionTiledGrid.cpp:96: error: undefined reference to 'rand'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./2d/CCActionTiledGrid.cpp:304: error: undefined reference to 'srand'
C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/../cocos2d/cocos/./2d/CCActionTiledGrid.cpp:670: error: undefined reference to 'srand'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make.exe: Leaving directory `C:/cocos2d-x-3.9/projects/TDProject/proj.android-studio/app'
Error running command, return code: 2.
I have the same problem. Initially working with API-23 and now I would like to test support for older phones. I’m trying to target API-19 and later. SO I change my --ap to android-19 while compiling and get all of the rand/srand/atof errors above. Is there any solution to this?
Could you clarify what you mean by this? If this solved your problem it should solve mine too. A little more detail on the steps you followed would be much appreciated.
I have just tried to do this and unfortunately the errors are still the same. Could you provide the file paths for the properties files you have been editing? It may also be important to note I’m compiling for android studio. My command line argument that produces the errors above is “cocos compile -p android --ap android-19 --android-studio”