一:NDK报错时的信息如下:
NDK出错信息如下:
10-19 14:46:53.036 111-355/? I/ALSAModule: Buffer size: 6144(frames) period Size: 2048(frames) periods: 3 (buffersize=periodSize*periods)
10-19 14:46:53.036 111-355/? I/ALSAModule: Latency: 139319 periodTime: 46439
10-19 14:46:53.096 27202-27243/? A/libc: Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27243 (Thread-243)
10-19 14:46:53.156 111-355/? I/ALSAModule: Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal
10-19 14:46:53.196 106-106/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-19 14:46:53.196 106-106/? I/DEBUG: Build fingerprint: 'rk30sdk/rk30sdk/rk30sdk:4.2.2/JDQ39/hdxyh.20151210.175924:eng/test-keys'
10-19 14:46:53.196 106-106/? I/DEBUG: Revision: '0'
10-19 14:46:53.196 106-106/? I/DEBUG: pid: 27202, tid: 27243, name: Thread-243 >>> cn.ndk.kndk <<<
10-19 14:46:53.196 106-106/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
10-19 14:46:53.306 106-106/? I/DEBUG: r0 00000000 r1 00000000 r2 632282c3 r3 632282c3
10-19 14:46:53.306 106-106/? I/DEBUG: r4 632282c3 r5 673defc0 r6 00000004 r7 6a88b7c8
10-19 14:46:53.306 106-106/? I/DEBUG: r8 6a88bc50 r9 677daf6c sl 673defd0 fp 6a88bc64
10-19 14:46:53.306 106-106/? I/DEBUG: ip 00000000 sp 6a88b488 lr 632282c3 pc 672d1612 cpsr 88000030
10-19 14:46:53.306 106-106/? I/DEBUG: d0 3ff00000000aae60 d1 6f65726549742400
10-19 14:46:53.306 106-106/? I/DEBUG: d2 202c70746c66202c d3 732f626b20373231
10-19 14:46:53.306 106-106/? I/DEBUG: d4 0000000000000000 d5 0000000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d6 0000000000000000 d7 3ff0000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d8 0000000000000000 d9 0000000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d10 0000000000000000 d11 0000000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d12 0000000000000000 d13 0000000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d14 0000000000000000 d15 0000000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d16 3ff0000000000000 d17 7e37e43c8800759c
10-19 14:46:53.306 106-106/? I/DEBUG: d18 3fdffffffffffd58 d19 3fe0000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d20 3fe0000000000154 d21 bf8aceb7c72ca160
10-19 14:46:53.306 106-106/? I/DEBUG: d22 3f81110c80ecb001 d23 be991627a5968807
10-19 14:46:53.306 106-106/? I/DEBUG: d24 3ff0000000000000 d25 3ff0000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d26 0000000000000000 d27 0000000000000005
10-19 14:46:53.306 106-106/? I/DEBUG: d28 0000000000000005 d29 3ff0000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: d30 3ff0000000000000 d31 3ff0000000000000
10-19 14:46:53.306 106-106/? I/DEBUG: scr 6000001f
10-19 14:46:53.306 106-106/? I/DEBUG: backtrace:
10-19 14:46:53.306 106-106/? I/DEBUG: #00 pc 00021612 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.306 106-106/? I/DEBUG: #01 pc 0001f381 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.306 106-106/? I/DEBUG: #02 pc 0001f1e7 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so (ffmpeg_parse_options+226)
10-19 14:46:53.306 106-106/? I/DEBUG: #03 pc 0000e0d5 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so (jxRun+212)
10-19 14:46:53.306 106-106/? I/DEBUG: #04 pc 00028c0b /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so (Java_cn_ndk_kndk_MainActivity_ffmpegRun+230)
10-19 14:46:53.306 106-106/? I/DEBUG: #05 pc 0001e290 /system/lib/libdvm.so (dvmPlatformInvoke+112)
10-19 14:46:53.306 106-106/? I/DEBUG: #06 pc 0004d411 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+396)
10-19 14:46:53.306 106-106/? I/DEBUG: #07 pc 0004f56f /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+174)
10-19 14:46:53.306 106-106/? I/DEBUG: #08 pc 000276a0 /system/lib/libdvm.so
10-19 14:46:53.306 106-106/? I/DEBUG: #09 pc 0002b57c /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
10-19 14:46:53.306 106-106/? I/DEBUG: #10 pc 0005fc31 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
10-19 14:46:53.306 106-106/? I/DEBUG: #11 pc 0005fc5b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
10-19 14:46:53.306 106-106/? I/DEBUG: #12 pc 000547d7 /system/lib/libdvm.so
10-19 14:46:53.306 106-106/? I/DEBUG: #13 pc 0000e3d8 /system/lib/libc.so (__thread_entry+72)
10-19 14:46:53.306 106-106/? I/DEBUG: #14 pc 0000dac4 /system/lib/libc.so (pthread_create+160)
10-19 14:46:53.306 106-106/? I/DEBUG: stack:
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b448 677daf6c
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b44c 673defd0
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b450 6a88bc64
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b454 67267ec4 /data/app-lib/cn.ndk.kndk-2/libavutil.so (av_log+84)
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b458 00000000
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b45c 6a88b46c
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b460 672db92e /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b464 632282c3 /data/dalvik-cache/system@framework@framework.jar@classes.dex
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b468 6a88b480
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b46c 672b86a1 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so (exit_program+64)
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b470 672be3e9 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b474 00000001
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b478 672db92e /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b47c 00000001
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b480 df0027ad
10-19 14:46:53.306 106-106/? I/DEBUG: 6a88b484 00000000
10-19 14:46:53.306 106-106/? I/DEBUG: #00 6a88b488 40086de4
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b48c 30202f20
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b490 33313678
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b494 36303734
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b498 202c2944
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b49c 30303834
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4a0 7a482030
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4a4 7473202c
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4a8 6f657265
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4ac 6c66202c
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4b0 202c7074
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4b4 20373231
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4b8 732f626b
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4bc 00000000
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4c0 00000002
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b4c4 67f5e4ec /data/app-lib/cn.ndk.kndk-2/libavformat.so
10-19 14:46:53.316 106-106/? I/DEBUG: ........ ........
10-19 14:46:53.316 106-106/? I/DEBUG: #01 6a88b7d0 6546a618
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7d4 64d09b41
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7d8 00000000
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7dc 672e2850 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7e0 6a88ba7c
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7e4 6a88b820
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7e8 672d0101 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7ec 672e281c /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7f0 6a88bbd8
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7f4 6a88b820
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7f8 64d09c00
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b7fc 672e0bff /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b800 672d0101 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b804 40086d08
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b808 00000000
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88b80c 00000000
10-19 14:46:53.316 106-106/? I/DEBUG: ........ ........
10-19 14:46:53.316 106-106/? I/DEBUG: #02 6a88ba30 672e5948 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba34 00000002
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba38 677daf6c
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba3c 673defd0
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba40 6a88bc64
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba44 67267ec4 /data/app-lib/cn.ndk.kndk-2/libavutil.so (av_log+84)
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba48 00000000
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba4c 6a88ba5c
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba50 672dcf6c /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba54 672bb1ed /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba58 672cf419 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba5c 672dc728 /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba60 672dd7bd /data/app-lib/cn.ndk.kndk-2/libjxffmpegrun.so
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba64 0000000a
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba68 6a88bbd8
10-19 14:46:53.316 106-106/? I/DEBUG: 6a88ba6c 6a88ba7c
10-19 14:46:53.316 106-106/? I/DEBUG: ........ ........
10-19 14:46:53.316 106-106/? I/DEBUG: memory near r2:
10-19 14:46:53.316 106-106/? I/DEBUG: 632282a0 1649025a 00000b25 0087025a 0000b1d2
10-19 14:46:53.316 106-106/? I/DEBUG: 632282b0 2995025a 0000b4fe 2c65025a 0000b94b
10-19 14:46:53.316 106-106/? I/DEBUG: 632282c0 0087025a 0000c43e 0087025a 0000c8cf
10-19 14:46:53.316 106-106/? I/DEBUG: 632282d0 2995025a 0000d58b 0087025a 0000d5c3
10-19 14:46:53.316 106-106/? I/DEBUG: 632282e0 12f8025a 000142ce 1ff0025a 00014dee
10-19 14:46:53.316 106-106/? I/DEBUG: 632282f0 1616025b 00000b25 1616025b 000111c2
10-19 14:46:53.316 106-106/? I/DEBUG: 63228300 19d6025b 000111c5 1616025c 00000b25
10-19 14:46:53.316 106-106/? I/DEBUG: 63228310 0536025c 0000ad66 12c3025c 0000ad66
10-19 14:46:53.316 106-106/? I/DEBUG: 63228320 2d9f025c 00010c14 2f13025c 00010c14
10-19 14:46:53.316 106-106/? I/DEBUG: 63228330 1616025d 00000b16 2682025d 00000b25
10-19 14:46:53.316 106-106/? I/DEBUG: 63228340 0551025d 00009362 2b3f025d 00009fa3
10-19 14:46:53.316 106-106/? I/DEBUG: 63228350 297e025d 0000a47f 297e025d 0000a49b
10-19 14:46:53.316 106-106/? I/DEBUG: 63228360 2d16025d 0000ac41 297e025d 0000ad1b
10-19 14:46:53.316 106-106/? I/DEBUG: 63228370 2cea025d 0000ad1c 054a025d 0000ad8d
10-19 14:46:53.316 106-106/? I/DEBUG: 63228380 054c025d 0000ad8e 054a025d 0000addf
10-19 14:46:53.316 106-106/? I/DEBUG: 63228390 054c025d 0000ade0 0549025d 0000ade4
不要看到内容很多就发憷,无论什么打印什么错误信息,仔细观察它对于我们解决错误肯定是有帮助的。
着重看backtrace与stack之间的内容,在这个之间又着重看我们自己的库文件,即包含libjxffmpegrun.so的前5行(特别是3,4,5行),可以看到,是我们自己编译的so文件和定义的两个函数,在这里引发了异常,导致程序崩溃,在这里我们记住重要信息,包括引起崩溃的库以及地址:libjxffmpegrun.so(0001f1e7,0000e0d5,00028c0b)
二:根据错误信息来找出错在哪里
方式1:使用arm-linux-androideabi-addr2line 定位出错位置,
注意此命令所在的文件夹:android-ndk-r10d\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-addr2line
以及此命令操作的文件是在文件夹下(eclipse的obj下):F:\simplest_ffmpeg_mobile\simplest_ffmpeg_android_helloworld\obj\local\armeabi
可以看到是在hello.c的70行报错
方式2:ndk-stack
注意此命令操作的文件是在文件夹下(eclipse的obj下): armeabi对应的是CPU架构目录,其他的比如x86架构等
可以看到右边的方框显示的是hello.c的70行报错
参考:http://blog.csdn.net/xyang81/article/details/42319789