配置 Android 手机
- 参考这篇文章 https://jingyan.baidu.com/article/ab69b2701577906ca6189f29.html 启用开发者模式
- 进入开发者选项---打开 USB 调试
配置 MacBook Pro
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- 安装 android-platform-tools
brew install --verbose android-platform-tools
adb devices
抓取崩溃和闪退日志信息
adb logcat | grep --color=always -E "AndroidRuntime|DEBUG"
崩溃的日志信息
- 对于崩溃信息,Java/Kotlin 层的会以 AndroidRuntime 为筛选关键字,比如这样的示例
11-07 18:40:34.699 15205 15205 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.affraud/com.app.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.app.MainActivity" on path: DexPathList[[zip file "/data/app/~~4mRtjAGRDA0TJSYel0KKOQ==/com.example.affraud-ARwolEciyGWrtHaCXTiCDA==/base.apk"],nativeLibraryDirectories=[/data/app/~~4mRtjAGRDA0TJSYel0KKOQ==/com.example.affraud-ARwolEciyGWrtHaCXTiCDA==/lib/arm64, /data/app/~~4mRtjAGRDA0TJSYel0KKOQ==/com.example.affraud-ARwolEciyGWrtHaCXTiCDA==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3737)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3980)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2394)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:211)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.os.Looper.loop(Looper.java:300)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8296)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
11-07 18:40:34.699 15205 15205 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
NDK 的闪退日志信息
- 因为我们使用 flutter,底层也严重依赖于 ndk 实现。 所以 ndk 闪退出现也是存在的,如下为一个典型的例子。
- 可以通过下面的
Cmdline: com.app
确定是否为 APP 的信息。
11-03 18:10:59.376 10450 10450 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-03 18:10:59.376 10450 10450 F DEBUG : Build fingerprint: 'Xiaomi/cetus/cetus:13/TKQ1.221013.002/V14.0.3.0.TJTCNXM:user/release-keys'
11-03 18:10:59.376 10450 10450 F DEBUG : Revision: '0'
11-03 18:10:59.376 10450 10450 F DEBUG : ABI: 'arm64'
11-03 18:10:59.376 10450 10450 F DEBUG : Timestamp: 2023-11-03 18:10:58.970304250+0800
11-03 18:10:59.376 10450 10450 F DEBUG : Process uptime: 1220s
11-03 18:10:59.376 10450 10450 F DEBUG : Cmdline: com.bybit.app
11-03 18:10:59.376 10450 10450 F DEBUG : pid: 29707, tid: 8696, name: com.app >>> com.app <<<
11-03 18:10:59.376 10450 10450 F DEBUG : uid: 10442
11-03 18:10:59.376 10450 10450 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000790
11-03 18:10:59.376 10450 10450 F DEBUG : Cause: null pointer dereference
11-03 18:10:59.376 10450 10450 F DEBUG : x0 0000000000000790 x1 22485561826a6104 x2 22485561826a6104 x3 0000000000000014
11-03 18:10:59.376 10450 10450 F DEBUG : x4 000000704db00d7d x5 0000000000000004 x6 0000000000000010 x7 7f7f7f7f7f7f7f7f
11-03 18:10:59.376 10450 10450 F DEBUG : x8 00000000b6a287d6 x9 0000000000000790 x10 00000000000021f8 x11 0000007052d8ec40
11-03 18:10:59.376 10450 10450 F DEBUG : x12 0000007052d8ec30 x13 00000000001ee010 x14 00000000001edc10 x15 ffffffffffffffff
11-03 18:10:59.376 10450 10450 F DEBUG : x16 0000000000000001 x17 000000711953da88 x18 0000006fdf7c6000 x19 0000006fe9996000
11-03 18:10:59.376 10450 10450 F DEBUG : x20 000000000000740b x21 000000704db01cb0 x22 000000000000740b x23 000000000000740b
11-03 18:10:59.376 10450 10450 F DEBUG : x24 000000704db01cb0 x25 000000704db01cb0 x26 000000704db01ff8 x27 00000000000fc000
11-03 18:10:59.376 10450 10450 F DEBUG : x28 00000000000fe000 x29 000000704db01c10
11-03 18:10:59.376 10450 10450 F DEBUG : lr 0000000000000000 sp 0000000000000000 pc 0000000000000790 pst 0000000060001000
11-03 18:10:59.376 10450 10450 F DEBUG : backtrace:
11-03 18:10:59.376 10450 10450 F DEBUG : #00 pc 0000000000000790 <unknown>
11-03 18:10:59.376 10450 10450 F DEBUG : #01 pc 0000000000000000 <unknown>