【问题标题】:How can I debug Cocos2d-x project in Android Studio?如何在 Android Studio 中调试 Cocos2d-x 项目?
【发布时间】:2016-01-01 06:16:01
【问题描述】:

环境:Cocos2d-x 3.9、Android Studio priview 2.0、ndk r10e(64位)、win10(64位)。
Cocos-console 似乎使用 NDK 将我所有的 cpp 组件编译成一个 libcocos2dcpp.so 文件。我设法编译了我的应用程序。它在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

所以我使用 addr2line 查看 00352a0c 的内容。但是,它只显示了 JNI_OnLoad。如果Sprite::create 可能返回nullptr,我应该在创建精灵后添加断言吗?

【问题讨论】:

    标签: android android-ndk cocos2d-x


    【解决方案1】:

    我经常使用 Cocos2d-x 的日志功能来查找应用程序崩溃的位置。

    (例如 log("sprite 开始... x = %f, y = %f", locationInNode.x, locationInNode.y);)

    您可以在 Android Studio 中按“cocos2d”过滤日志消息,以查看有关您的 cocos2d-x 应用的所有日志。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-08
      • 1970-01-01
      相关资源
      最近更新 更多