Android build probelm

hello,
i have implement code in c++
iOS build is working very well but in android build it compiles successfully and created a .apk file but when i install it and open it directly ommit error “Unfortunately stopped”
i am using version 3.14
and i have tried it for hellowold demo also but same error is there also
please provide me a solution
i am helpless.

Take a look to logcat and send stack trace.

how to do that
i have made apk from terminal

Use
adb logcat
or run android studio as it have logcat view included.

so for make a android build i have to open the project in android studio
there is no option for this terminal use

Did you compile source code after build for Android. For iOS you just need to build then run project from xCode, but with Android, you need additional step to compile to C++ source then run it from Android studio

ok
thanks
please help me to get that additional steps for that

You just need to open Build dialog, click Build button first, then click Compile button

this is the logcat error
02-03 17:01:05.434 3017-3017/? E/memtrack: Couldn’t load memtrack module (No such file or directory)
02-03 17:01:05.434 3017-3017/? E/android.os.Debug: failed to load memtrack module: -2
02-03 17:01:07.495 3031-3031/? E/memtrack: Couldn’t load memtrack module (No such file or directory)
02-03 17:01:07.495 3031-3031/? E/android.os.Debug: failed to load memtrack module: -2

I don’t think these are errors from this app.

You can open any project (or even make empty one) and open logcat (android monitor), there you can filter logs for errors only and find stacktrace.

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.