原帖: http://stackoverflow.com/questions/18436383/how-to-check-crash-log-using-android-ndk-in-cocos2d-x
当mac用Elipse调试android真机的时候,有时候app会崩溃,LogCat里面只会出现一句错误提示:
让开发者毫无头绪。这时候可以用下面两个命令行查看详细的错误日志:
$ export ANDROID_NDK_ROOT=/Users/wenke/Documents/tools/cocos2d/android/android-ndk-r9b
$ export PROJECT_PATH=/Users/wenke/Documents/cocos2d/cocos2d-x-2.2/projects/zha_jin_hua/proj.android/
$ cd $ANDROID_NDK_ROOT
$ adb logcat | ./ndk-stack -sym $PROJECT_PATH/obj/local/armeabi
显示的log如下:
********** Crash dump: **********
Build fingerprint: 'samsung/hltezm/hlte:4.3/JSS15J/N9008VZMUBNA2:user/release-keys'
pid: 30558, tid: 30587, name: Thread-12345 >>> com.dcgame.zhajinhua <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000003
Stack frame #00 pc 0000f90a /system/lib/libc.so (dlmalloc+513)
Stack frame #01 pc 0000db33 /system/lib/libc.so (malloc+10)
Stack frame #02 pc 0000091b /system/lib/libstdc++.so (operator new(unsigned int)+2)
Stack frame #03 pc 0012b0a0 /system/lib/libskia.so (SkFontHost::CreateScalerContext(SkDescriptor const*)+12)
Stack frame #04 pc 000d3938 /system/lib/libskia.so (SkScalerContext::getNextContext()+244)
Stack frame #05 pc 000d39b4 /system/lib/libskia.so (SkScalerContext::getContextFromChar(int, unsigned int&)+56)
Stack frame #06 pc 000d3a68 /system/lib/libskia.so (SkScalerContext::charToGlyphID(int)+12)
Stack frame #07 pc 000b586c /system/lib/libskia.so (SkPaint::textToGlyphs(void const*, unsigned int, unsigned short*) const+232)
Stack frame #08 pc 0008087b /system/lib/libandroid_runtime.so
Stack frame #09 pc 00037e0c /system/lib/libharfbuzz_ng.so
Stack frame #10 pc 00027e9c /system/lib/libharfbuzz_ng.so
Stack frame #11 pc 0000d19c /system/lib/libharfbuzz_ng.so (hb_shape_plan_execute+208)
Stack frame #12 pc 0000caec /system/lib/libharfbuzz_ng.so (hb_shape_full+80)
Stack frame #13 pc 0000cb24 /system/lib/libharfbuzz_ng.so (hb_shape+16)
Stack frame #14 pc 00086693 /system/lib/libandroid_runtime.so (android::TextLayoutShaper::shapeFontRun(SkPaint const*)+202)
Stack frame #15 pc 00086833 /system/lib/libandroid_runtime.so (android::TextLayoutShaper::computeRunValues(SkPaint const*, unsigned short const*, unsigned int, unsigned int, unsigned int, bool, android::Vector<float>*, float*, android::Vector<unsigned short>*, android::Vector<float>*)+398)
Stack frame #16 pc 00086b25 /system/lib/libandroid_runtime.so (android::TextLayoutShaper::computeValues(SkPaint const*, unsigned short const*, unsigned int, unsigned int, unsigned int, int, android::Vector<float>*, float*, android::Vector<unsigned short>*, android::Vector<float>*)+424)
Stack frame #17 pc 00086bcd /system/lib/libandroid_runtime.so (android::TextLayoutShaper::computeValues(android::TextLayoutValue*, SkPaint const*, unsigned short const*, unsigned int, unsigned int, unsigned int, int)+44)
Stack frame #18 pc 000870a3 /system/lib/libandroid_runtime.so (android::TextLayoutCache::getValue(SkPaint const*, unsigned short const*, int, int, int, int)+266)
Stack frame #19 pc 000873a7 /system/lib/libandroid_runtime.so (android::TextLayoutEngine::getValue(SkPaint const*, unsigned short const*, int, int, int, int)+34)
Stack frame #20 pc 00085b33 /system/lib/libandroid_runtime.so (android::TextLayout::getTextRunAdvances(SkPaint*, unsigned short const*, int, int, int, int, float*, float*)+42)
Stack frame #21 pc 0008252d /system/lib/libandroid_runtime.so
Stack frame #22 pc 00020c0c /system/lib/libdvm.so (dvmPlatformInvoke+112)
Stack frame #23 pc 0005178b /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
Stack frame #24 pc 0002a0a0 /system/lib/libdvm.so
Stack frame #25 pc 0002ea80 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
Stack frame #26 pc 0006390d /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
Stack frame #27 pc 0004d35f /system/lib/libdvm.so
Stack frame #28 pc 001dd105 /data/app-lib/com.dcgame.zhajinhua-2/libcocos2dcpp.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+18): Routine CallStaticVoidMethod in /Users/wenke/Documents/tools/cocos2d/android/android-ndk-r9b/platforms/android-19/arch-arm/usr/include/jni.h:807
Stack frame #29 pc 002585eb /data/app-lib/com.dcgame.zhajinhua-2/libcocos2dcpp.so (cocos2d::BitmapDC::getBitmapFromJavaShadowStroke(char const*, int, int, cocos2d::CCImage::ETextAlign, char const*, float, float, float, float, bool, float, float, float, float, bool, float, float, float, float)+302): Routine getBitmapFromJavaShadowStroke in (null):0
Stack frame #30 pc 0025873f /data/app-lib/com.dcgame.zhajinhua-2/libcocos2dcpp.so (cocos2d::CCImage::initWithStringShadowStroke(char const*, int, int, cocos2d::CCImage::ETextAlign, char const*, int, float, float, float, bool, float, float, float, float, bool, float, float, float, float)+104): Routine initWithStringShadowStroke in /Users/wenke/Documents/cocos2d/cocos2d-x-2.2/projects/zha_jin_hua/proj.android/../../../cocos2dx/platform/android/CCImage.cpp:225
Stack frame #31 pc 0026a29b /data/app-lib/com.dcgame.zhajinhua-2/libcocos2dcpp.so (cocos2d::CCTexture2D::initWithString(char const*, cocos2d::_ccFontDefinition*)+430): Routine initWithString in (null):0
Crash dump is completed
这样对定位错误位置,多少有些帮助!