一、在Android开发中,我们经常遇到以下错误:
AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
06-28 16:08:29.715 12954 12954 D AndroidRuntime: Calling main entry com.android.commands.wm.Wm
06-28 16:08:29.721 12954 12954 D AndroidRuntime: Shutting down VM
06-28 16:08:39.604 13095 13095 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-28 16:08:39.604 13095 13095 F DEBUG : Native Crash TIME: 7569125
06-28 16:08:39.604 13095 13095 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-28 16:08:39.604 13095 13095 F DEBUG : Build fingerprint: 'SPRD/sl8541e_cus_gofu_osea/sl8541e_cus_go:8.1.0/OPM2.171019.012/21411:user/release-keys'
06-28 16:08:39.604 13095 13095 F DEBUG : Revision: '0'
06-28 16:08:39.604 13095 13095 F DEBUG : ABI: 'arm'
06-28 16:08:39.605 13095 13095 F DEBUG : pid: 12972, tid: 13079, name: Thread-3 >>> com.zqc.a8541camera2 <<<
06-28 16:08:39.605 13095 13095 F DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x8c162ebc
06-28 16:08:39.605 13095 13095 F DEBUG : r0 8c000000 r1 8c000000 r2 c03675c2 r3 00000000
06-28 16:08:39.605 13095 13095 F DEBUG : r4 c03675c2 r5 8c25d970 r6 8c25d970 r7 8c1632e8
06-28 16:08:39.605 13095 13095 F DEBUG : r8 000032ac r9 000032ac sl 8cb8faf5 fp 0000000b
06-28 16:08:39.605 13095 13095 F DEBUG : ip 8cbb2e4c sp 8c162ea8 lr 8cb94179 pc 8cb97e86 cpsr a0000030
06-28 16:08:39.625 13095 13095 F DEBUG :
06-28 16:08:39.625 13095 13095 F DEBUG : backtrace:
06-28 16:08:39.625 13095 13095 F DEBUG : #00 pc 00013e86 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so
06-28 16:08:39.625 13095 13095 F DEBUG : #01 pc 00010175 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so (RTMP_Close+56)
06-28 16:08:39.626 13095 13095 F DEBUG : #02 pc 00013bb7 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so
06-28 16:08:39.626 13095 13095 F DEBUG : #03 pc 00013115 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so (RTMP_SendPacket+860)
06-28 16:08:39.626 13095 13095 F DEBUG : #04 pc 00013f21 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so
06-28 16:08:39.626 13095 13095 F DEBUG : #05 pc 00010175 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so (RTMP_Close+56)
06-28 16:08:39.626 13095 13095 F DEBUG : #06 pc 00013bb7 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so
06-28 16:08:39.626 13095 13095 F DEBUG : #07 pc 00013115 /data/app/com.zqc.a8541camera2-yjjIhrmWTd12F-xDcNb2IA==/lib/arm/libnative-lib.so (RTMP_SendPacket+860)
其中backtrace下面就是报错的位置
二、找到出错的内存地址
这里我们就找到了“libnative-lib.so”的错误地址是“00013e86”,这样就定位到了C++代码出错的地址了。
三、转换获取出错的具体文件和行数,下面是完成执行命令
G:\wangqi\AndroidStudio\Android\Sdk\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin> .\arm-linux-androideabi-addr2line.exe -C -f -e G:\wangqi\work\a8541camera2Push\app\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so 00013bb7