Android build probelm

sory
the error is as below

02-03 17:19:01.931 5273-5273/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.jdbtechs.tictactoe, PID: 5273
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol “rand” referenced by “libMyGame.so”…
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:526)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:264)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

Try running app with parameter: “–ap android-10”

@piotrros so try it from terminal with --ap android-10 ?

yes, in terminal

cocos run -p android --ap android-10

this error occurs:

Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./platform/CCFileUtils.cpp:274: error: undefined reference to ‘atof’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./platform/CCFileUtils.cpp:283: error: undefined reference to ‘atof’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./base/CCConsole.cpp:1224: error: undefined reference to ‘srand’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./base/CCConsole.cpp:1225: error: undefined reference to ‘rand’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./base/CCConsole.cpp:1253: error: undefined reference to ‘srand’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./base/CCConsole.cpp:1254: error: undefined reference to ‘rand’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./base/ccUtils.cpp:254: error: undefined reference to ‘atof’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./base/ccRandom.h:117: error: undefined reference to ‘rand’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./2d/CCActionTiledGrid.cpp:87: error: undefined reference to ‘rand’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./2d/CCActionTiledGrid.cpp:278: error: undefined reference to ‘srand’
/Users/jaydeeprudani/Desktop/TicTacToe/cocos2d/cocos/./2d/CCActionTiledGrid.cpp:603: error: undefined reference to ‘srand’

Looks like your problem is related to this one:

Try using different versions, for example android-19.

I know, it’s ndk hell :slight_smile:

edit:

what cocos2d-x are you using?

i am using cocos2d-x-3.14
same error occur with android-19

Are you created this project from scratch while using 3.14 or it’s an old project or downloaded from somewhere? I suspect you may have old cocos2d-x files inside your project.

Can you create new empty project and try running it on android? If it works you may copy classes and resources from your project and it should work.

i have downloaded new version and change it to new version and make my project
but when i am creating new project.it is also not working for me
why this happens
i don’t know

What NDK version are you using?
You can update it from Android Studio.

i am using android-ndk-r13b
need to update it???

That’s the latest (stable) version, so it’s fine.

Well that’s strange.

so there is no solution for this?

Sure there is. I just don’t know atm why it happens.
I use the same cocos2d-x and ndk versions and have no such problem.
Especially strange that it also happens on fresh new project.
You may wait for someone from community or google this error, there’re plenty of occurrences.

@slackmoehrle please provide a solution for this
i am stuck in this

Are you running on hardware or in an emulator? If an emulator try hardware.

@slackmoehrle i am running it in hardware
same problem is there

@slackmoehrle please provide me a solution
i am stuck in this problem

Did you try the link by @piotrros. This error has come up here before. Try searching these forums for it.

@slackmoehrlei have tried that all the solutions but it would not work for me