【发布时间】:2020-08-25 07:35:05
【问题描述】:
我正在尝试设置我的 Android 项目,以按照 Firebase Crashlytics NDK documentation 中定义的步骤使用 Firebase Crashlytics SDK 报告 NDK 崩溃。我尝试通过添加以下代码使用 Firebase Crashlytics SDK(而不是 NDK 库)报告崩溃,并且成功报告了崩溃。
releaseImplementation 'com.google.firebase:firebase-crashlytics:17.1.1'
我应用的更改正在更改 NDK 的库:
releaseImplementation 'com.google.firebase:firebase-crashlytics-ndk:17.2.1'
并将文档中提到的本地符号上传添加到应用程序 gradle 文件中
buildTypes {
release {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
}
}
}
我在logcat上看到的错误是:
2020-08-25 08:39:24.859 16889-16889/? I/CrashlyticsInitProvider: CrashlyticsInitProvider skipping initialization
2020-08-25 08:39:27.258 16889-16889/? I/CrashlyticsCore: Initializing Crashlytics Core 2.7.0.33
2020-08-25 08:39:36.980 17454-17454/? E/FirebaseCrashlytics: libcrashlytics could not be loaded. This APK may not have been compiled for this device's architecture. NDK crashes will not be reported to Crashlytics:
JNI_ERR returned from JNI_OnLoad in "/data/app/com.mypackagename==/lib/arm64/libcrashlytics.so"
2020-08-25 08:39:37.392 17454-17454/? I/FirebaseCrashlytics: Initializing Crashlytics 17.2.1
2020-08-25 08:39:37.762 17454-17498/? I/FirebaseCrashlytics: Crashlytics NDK initialization FAILED
2020-08-25 08:39:39.661 17530-17530/? E/FirebaseCrashlytics: libcrashlytics could not be loaded. This APK may not have been compiled for this device's architecture. NDK crashes will not be reported to Crashlytics:
JNI_ERR returned from JNI_OnLoad in "/data/app/com.mypackagename==/lib/arm64/libcrashlytics.so"
在为 NDK 替换库之前,我可以强制 Java 崩溃并且应用程序立即崩溃,但是在添加 NDK 时,应用程序似乎挂起(如 ANR)并且没有立即崩溃(可能是因为库可以'找不到?)
在logcat中显示:
2020-08-25 08:43:43.472 22214-22238/? I/FirebaseCrashlytics: Crashlytics NDK initialization FAILED
2020-08-25 08:43:43.538 22214-22325/? D/TransportRuntime.SQLiteEventStore: Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct
2020-08-25 08:43:43.561 22214-22341/? D/TransportRuntime.SQLiteEventStore: Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct
2020-08-25 08:43:43.579 22214-22342/? D/TransportRuntime.SQLiteEventStore: Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct
2020-08-25 08:43:43.591 22214-22343/? D/TransportRuntime.SQLiteEventStore: Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct
2020-08-25 08:43:50.150 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.n0.a(SourceFile:1)
2020-08-25 08:43:50.150 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.d.run(SourceFile:2)
2020-08-25 08:43:50.150 22214-22338/? A/com.mypackagename: runtime.cc:574] "com.google.firebase.crashlytics.startup1" prio=5 tid=17 Waiting
2020-08-25 08:43:50.151 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.n0.a(SourceFile:1)
2020-08-25 08:43:50.151 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.d.run(SourceFile:2)
2020-08-25 08:43:50.172 22214-22338/? A/com.mypackagename: runtime.cc:574] native: #12 pc 00000000001a0c86 /data/app/com.mypackagename==/oat/arm64/base.vdex (com.google.firebase.crashlytics.d.m.j0.uncaughtException+86)
2020-08-25 08:43:50.173 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.Z.M(SourceFile:-1)
2020-08-25 08:43:50.173 22214-22338/? A/com.mypackagename: runtime.cc:574] - waiting to lock <0x06ca8488> (a com.google.firebase.crashlytics.d.m.Z) held by thread 13
2020-08-25 08:43:50.173 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.j0.uncaughtException(SourceFile:5)
2020-08-25 08:43:50.177 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.Z.M(SourceFile:-1)
2020-08-25 08:43:50.178 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.Z.M(SourceFile:-1)
2020-08-25 08:43:50.178 22214-22338/? A/com.mypackagename: runtime.cc:574] at com.google.firebase.crashlytics.d.m.j0.uncaughtException(SourceFile:5)
2020-08-25 08:43:50.178 22214-22338/? A/com.mypackagename: runtime.cc:574] native: #06 pc 000000000019f15c /data/app/com.mypackagename==/oat/arm64/base.vdex (com.google.firebase.crashlytics.d.m.Z.M)
2020-08-25 08:43:50.178 22214-22338/? A/com.mypackagename: runtime.cc:574] native: #12 pc 00000000001a0c86 /data/app/com.mypackagename==/oat/arm64/base.vdex (com.google.firebase.crashlytics.d.m.j0.uncaughtException+86)
请注意,本机代码与项目一起编译并位于 jni 文件夹中,可以正常工作(因此它适用于所有 ABI)。我尝试在发布时运行并从 Build>Generate signed Bundle/APK 生成签名的 APK。
【问题讨论】:
标签: android firebase android-ndk crashlytics crashlytics-android