简体   繁体   English

如何在Android Studio中调试Cocos2d-x项目?

[英]How can I debug Cocos2d-x project in Android Studio?

Environment: Cocos2d-x 3.9, Android Studio priview 2.0, ndk r10e (64-bit), win10(64bit). 环境:Cocos2d-x 3.9,Android Studio priview 2.0,ndk r10e(64位),win10(64位)。
Cocos-console seems to use NDK to compile all my cpp component into one libcocos2dcpp.so file. Cocos-console似乎使用NDK将我所有的cpp组件编译到一个libcocos2dcpp.so文件中。 I managed to get my app compiled. 我设法编译了我的应用程序。 It ran well on win32, but crashed on Android. 它在win32上运行良好,但在Android上崩溃了。

I/DEBUG: Build fingerprint: 'samsung/h3gzc/hlte:5.0/LRX21V/N9006ZCUGOH2:user/release-keys'
I/DEBUG: Revision: '8'
I/DEBUG: ABI: 'arm'
I/DEBUG: pid: 2561, tid: 2561, name: Zzzen.YourWorld  >>> com.github.Zzzen.YourWorld <<<
I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
I/DEBUG:     r0 b4f512b0  r1 1fffffff  r2 2e7e0d8d  r3 b4f512b0
I/DEBUG:     r4 00000043  r5 b4f18228  r6 a20f99e4  r7 00000000
I/DEBUG:     r8 b4f07800  r9 b4efac64  sl bef10b58  fp bef10984
I/DEBUG:     ip a275abd0  sp bef10978  lr a20f9a10  pc 00000000  cpsr 600f0010
I/DEBUG:     #00 pc 00000000  <unknown>
I/DEBUG:     #01 pc 00352a0c  /data/app/com.github.Zzzen.YourWorld-1/lib/arm/libcocos2dcpp.so (JNI_OnLoad+40)
I/DEBUG:     #02 pc 001d5357  /system/lib/libart.so (art::JavaVMExt::LoadNativeLibrary(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, art::Handle<art::mirror::ClassLoader>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)+1478)
I/DEBUG:     #03 pc 001fd061  /system/lib/libart.so (art::Runtime_nativeLoad(_JNIEnv*, _jclass*, _jstring*, _jobject*, _jstring*)+548)
I/DEBUG:     #04 pc 00019811  /system/framework/arm/boot.oat

So I used addr2line to see what's at 00352a0c. 因此,我使用addr2line查看00352a0c的内容。 However, It just showed JNI_OnLoad. 但是,它仅显示了JNI_OnLoad。 Should I add assertions after creating a sprite in case Sprite::create may return nullptr ? 在创建Sprite之后是否应该添加断言,以防Sprite::create可能返回nullptr

I often use Cocos2d-x 's log function to find out where the app crash. 我经常使用Cocos2d-x的log函数来查找应用程序崩溃的位置。

(eg log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);) (例如log(“ sprite starts ... x =%f,y =%f”,locationInNode.x,locationInNode.y);)

You can filter the log messages by 'cocos2d' in Android studio to see all logs about your cocos2d-x app. 您可以在Android Studio中按“ cocos2d”过滤日志消息,以查看有关cocos2d-x应用程序的所有日志。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM