Sunday, 15 January 2012

c++ - How to debug cocos2d-x 3 native code on android device -



c++ - How to debug cocos2d-x 3 native code on android device -

i not find cookbook/tutorial how build in debug build cocos2d-x 3.1 project android , how debug straight on device. please help pointing out steps.

what , problems have:

cd proj.android cocos compile -p android -m debug --ndk-mode ndk_debug=1 (to build debug info) cocos run -p android -m debug deploy on device run app on device cd jni ndk-gdb

and error:

nareks-macbook-pro:jni narek$ ndk-gdb jni/android.mk:67: *** android ndk: aborting. . stop. error: device not back upwards application's targetted cpu abis! device supports: armeabi-v7a armeabi bundle supports: android ndk:

into application.mk have added:

app_abi := armeabi armeabi-v7a app_platform := android-10

but did not help. wrong?

edit: adding result of ndk-build dump_app_abi command called in projects jni directory:

nareks-macbook-pro:jni narek$ ndk-build dump_app_abi android ndk: /users/narek/noorgames/games/test2/proj.android/jni/android.mk: cannot find module tag '.' in import path android ndk: sure ndk_module_path variable defined ? android ndk: next directories searched: android ndk: /users/narek/noorgames/games/test2/proj.android/jni/android.mk:67: *** android ndk: aborting. . stop.

here step-by-stet tutorial debug cocos2d-x 3.x on android device. please right or optimize steps if in improve way.

cd proj.android cocos compile -p android -m debug --ndk-mode ndk_debug=1 (to build debug info) cocos run -p android -m debug deploy on device (sometimes rebuilds, , don't know why). command uninstalls former installation, installs new 1 , runs app on device. make sure in proj.android/libs/armeabi directory have next files gdb.setup, gdbserver, libcocos2dcpp.so also create sure in /proj.android/jni/obj/local/armeabi directory have app_process, gdb.setup, libc.so, linker ndk-gdb (important! should called in projects directory, not in jni directory)

if worked congratulations! in step may see such error message:

nareks-macbook-pro:proj.android narek$ ndk-gdb jni/android.mk:67: *** android ndk: aborting. . stop. error: device not back upwards application's targetted cpu abis! device supports: armeabi-v7a armeabi bundle supports: android ndk:

don't worry :). lets see wrong:

here result of ndk-build dump_app_abi command called in project's jni directory:

nareks-macbook-pro:jni narek$ ndk-build dump_app_abi android ndk: /users/narek/noorgames/games/test2/proj.android/jni/android.mk: cannot find module tag '.' in import path android ndk: sure ndk_module_path variable defined ? android ndk: next directories searched: android ndk: /users/narek/noorgames/games/test2/proj.android/jni/android.mk:67: *** android ndk: aborting. . stop.

as can see ndk_module_path missing. obtaining value following. go step compiled code. in first linse of execution of command cocos compile -p android -m debug --ndk-mode ndk_debug=1 can see this:

runing command: compile building mode: debug building native ndk build mode: ndk_debug=1 selected ndk toolchain version 4.8 ! running: '/users/narek/noorgames/android-ndk-r9d/ndk-build -c /users/narek/noorgames/games/test2/proj.android -j1 ndk_module_path=/users/narek/noorgames/games/test2/proj.android/../cocos2d:/users/narek/noorgames/games/test2/proj.android/../cocos2d/cocos:/users/narek/noorgames/games/test2/proj.android/../cocos2d/external' copy log above see necessary value of ndk_module_path. execute next command export ndk_module_path=/users/narek/noorgames/games/test2/proj.android/../cocos2d:/users/narek/noorgames/games/test2/proj.android/../cocos2d/cocos:/users/narek/noorgames/games/test2/proj.android/../cocos2d/external (be attentive re-create path not mine)

that's it. run game on device, cd proj.android, phone call ndk-gdb , should able debug gdb.

i looked kind of tutorial more 20 days. hope enjoy debugging already. :) , give thanks @vikaspatidar help ndk-build dump_app_abi step!

edit1: commented vikas can add together ndk_module_path in android.mk file this:

ndk_module_path := $(local_path)/../../../../cocos ndk_module_path += $(local_path)/../../../../external

edit2: if app crashed here powerful , easy way investigate problem preventing direct debugging:

adb logcat | $ndk_root/ndk-stack -sym $project_path/obj/local/armeabi

it prints crash dump.

c++ cocos2d-x cocos2d-x-3.0

No comments:

Post a Comment