JNI崩溃了,系统日志会打印堆栈信息,所以第一步就是取日志
adb shell logcat -v threadtime >>d:/log.txt
然后找到日志里面的关键字backtrace例如我的日志是这样的
12-04 06:14:38.362 3773 3773 F DEBUG : backtrace: 12-04 06:14:38.363 3773 3773 F DEBUG : #00 pc 00014d9a /data/app/com.cloudtv.xdogact-1/lib/arm/liblocalser.so 12-04 06:14:38.363 3773 3773 F DEBUG : #01 pc 0000d741 /data/app/com.cloudtv.xdogact-1/lib/arm/liblocalser.so (_Z9WriteHeadR4CUrl+472) 12-04 06:14:38.363 3773 3773 F DEBUG : #02 pc 0000e895 /data/app/com.cloudtv.xdogact-1/lib/arm/liblocalser.so (_Z6runSerRVb+1176) 12-04 06:14:38.363 3773 3773 F DEBUG : #03 pc 0000a999 /data/app/com.cloudtv.xdogact-1/lib/arm/liblocalser.so (_Z5DoSerPv+4)
现在想定位第三行,就是0000d741对应代码的位置,就只需要把代码填入下面的脚本进替换,然后执行就OK了
#!/bin/bash dir=$(pwd) export PATH=$PATH:/android-ndk-r11c/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/ export PATH=$PATH:/android-ndk-r11c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin addr=0000d741 arm-linux-androideabi-addr2line -e $dir/obj/local/armeabi-v7a/liblocalser.so $addr aarch64-linux-android-addr2line -e $dir/obj/local/arm64-v8a/liblocalser.so $addr