Firebase Crashlytics不支持NDK?

时间:2018-06-22 11:20:32

标签: android firebase android-ndk crashlytics crashlytics-android

当您要使用 Crashlytics NDK 时,您需要致电Fabric.with(this, new Crashlytics(),new CrashlyticsNdk());,但Firebase Crashlytics会致电 Fabric.with(context, new Kit[]{new Crashlytics()});在启动时。 结果,您将无法使用Crashlytics NDK。

如何避免这个问题?

public class CrashlyticsInitProvider extends ContentProvider {
private static final String TAG = "CrashlyticsInitProvider";

public CrashlyticsInitProvider() {
}

public boolean onCreate() {
    Context context = this.getContext();
    FirebaseInfo firebaseInfo = new FirebaseInfo();
    CrashlyticsInitProvider.EnabledCheckStrategy enabledCheckStrategy = new ManifestEnabledCheckStrategy();
    if (this.shouldInitializeFabric(context, firebaseInfo, enabledCheckStrategy)) {
        try {
            Fabric.with(context, new Kit[]{new Crashlytics()}); // !here
            Fabric.getLogger().i("CrashlyticsInitProvider", "CrashlyticsInitProvider initialization successful");
        } catch (IllegalStateException var5) {
            Fabric.getLogger().i("CrashlyticsInitProvider", "CrashlyticsInitProvider initialization unsuccessful");
            return false;
        }
    }

    return true;
}

2 个答案:

答案 0 :(得分:1)

将此添加到您的AndroidManifest.xml

<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />

然后在您的Application子类中手动初始化Crashlytics:

Fabric fabric = new Fabric.Builder(this)
                .kits(new Crashlytics(), new CrashlyticsNdk())
                .build();
Fabric.with(fabric);

请参见https://firebase.google.com/docs/crashlytics/force-a-crash#enable_debug_mode

答案 1 :(得分:0)

Firebase Crashlytics SDK已支持Android NDK崩溃报告。在使用Firebase Crashlytics SDK设置了Crashlytics之后,您可以将以下内容添加到app/build.gradle中:

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

dependencies {
    // ...

    // Add the Crashlytics NDK dependency.
    implementation 'com.google.firebase:firebase-crashlytics-ndk:17.0.0-beta01'
}

// …
android {
    // ...
    buildTypes {
        release {
            // Add this extension
            firebaseCrashlytics {
                // Enable processing and uploading of native symbols to Crashlytics
                // servers. By default, this is disabled to improve build speeds.
                // This flag must be enabled to see properly-symbolicated native
                // stack traces in the Crashlytics dashboard.
                nativeSymbolUploadEnabled true
            }
        }
    }
}

在此处查看更多信息:https://firebase.google.com/docs/crashlytics/ndk-reports-new-sdk