未初始化Firebase Crashlytics NDK无法加载Libcrashlytics

问题描述

我正在尝试按照Firebase Crashlytics NDK documentation上定义的步骤,通过Firebase Crashlytics SDK报告Android 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> Generatesigned Bundle / APK生成签名的APK。

解决方法

从您的日志中:2020-08-25 08:39:27.258 16889-16889/? I/CrashlyticsCore: Initializing Crashlytics Core 2.7.0.33

这意味着在您的代码库中某个地方引用了旧的Fabric Crashlytics SDK的依赖项。您的安装程序中同时包含Fabric和Firebase Crashlytics SDK的元素,很可能导致您遇到错误。确保您的代码库中没有任何内容可以引用旧的Fabric SDK,并且您已遵循upgrade instructions here来将新SDK的旧SDK完全更改为新版本。

,

在@Kevin Kokomani的回答中,您可以遵循this simple guide来了解如何为应用程序的NDK层正确设置Firebase Crashlytics。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...