I'm trying to set up my Android project to report NDK crashes with Firebase Crashlytics SDK following the steps defined on Firebase Crashlytics NDK documentation . I tried reporting crashes with Firebase Crashlytics SDK (not the NDK library) by adding the following code and crashes are reported sucessfully.
releaseImplementation 'com.google.firebase:firebase-crashlytics:17.1.1'
The changes that I have applied are changing the library for the NDK one:
releaseImplementation 'com.google.firebase:firebase-crashlytics-ndk:17.2.1'
and adding the native symbol upload as the doc mentions into the app gradle file
buildTypes {
release {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
}
}
}
The error I see on the logcat is:
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"
Before replacing the library for the NDK one I can force Java crash and the app crashes immediately, but when adding the NDK one, the app seems to hang (like and ANR) and not crashing immediately (probably because the library can't be found?)
In the logcat is displayed:
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)
Note that the native code is compiled with the project and is found on the jni folder, working properly (so it works for all the ABIs). I tried running on release and generating a signed APK from Build>Generate signed Bundle/APK.