简体   繁体   中英

Unable to get provider com.crashlytics.android.CrashlyticsInitProvider

After implementation 'com.google.firebase:firebase-core:16.0.1' and classpath 'com.google.gms:google-services:4.0.1'

I started getting the following error when starting the application:

FATAL EXCEPTION: main Process: com.fentury.android, PID: 10771 java.lang.RuntimeException: Unable to get provider com.crashlytics.android.CrashlyticsInitProvider: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up , install an Android build tool and ask a team member to invite you to this app's organization. at android.app.ActivityThread.installProvider(ActivityThread.java:5856) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up , install an Android build tool and ask a team member to invite you to this app's organization. at com.crashlytics.android.core.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:235) at com.crashlytics.android.core.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:209) at io.fabric.sdk.android.InitializationTask.onPreExecute(InitializationTask.java:44) at io.fabric.sdk.android.services.concurrency.AsyncTask.executeOnExecutor(AsyncTask.java:611) at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.executeOnExecutor(PriorityAsyncTask.java:43) at io.fabric.sdk.android.Kit.initialize(Kit.java:69) at io.fabric.sdk.android.Fabric.initializeKits(Fabric.java:440) at io.fabric.sdk.android.Fabric.init(Fabric.java:384) at io.fabric.sdk.android.Fabric.setFabric(Fabric.java:342) at io.fabric.sdk.android.Fabric.with(Fabric.java:313) at com.crashlytics.android.CrashlyticsInitProvider.onCreate(CrashlyticsInitProvider.java:27) at android.content.ContentProvider.attachInfo(ContentProvider.java:1751) at android.content.ContentProvider.attachInfo(ContentProvider.java:1726) at android.app. ActivityThread.installProvider(ActivityThread.java:5853) ... 10 more

Also added in AndroidManifest.xml next line:

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

This helped to solve my problem

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

And remove this:

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

I found that the only thing you need to do after following the instruction on the Firebase Crashlytics docs is to apply the fabric plugin in your app build file (This step is actually missing from the docs!).

In your app-level build.gradle add the following

// Apply the Fabric plugin
apply plugin: 'io.fabric'

Edit: It appears that this step has been recently added to the docs (See Step 2 / part 2).

If you are going to use other Firebase's API's, I'd suggest to setup crashlytics
As mentioned on Firebase's crashlytics page, here .

And obviously before that you'd need to setup firebase for your app
and create project through firebase console.
I believe you had already done that.

It's because I see small difference in crashlytics setup on these two pages(fabric and firebase).
like on firebase's crashlytics:
in app level gradle

dependencies {
    // ...
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
}

on fabric:

dependencies {
    // ...
      implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
    transitive = true;
  }
}

You won't need to add fabric api key through manifest if you are using with firebase, I think it somehow get connected with firebase key(just guessing).
I'm saying this from my experience, anyone correct me if I'm somewhere wrong.

I ran into this issue as well it was caused by using the incorrect Fabric.with() initializer for debug builds.

Don't use:

// Set up Crashlytics, disabled for debug builds
Crashlytics crashlyticsKit = new Crashlytics.Builder()
        .core(new CrashlyticsCore.Builder()
                .disabled(BuildConfig.DEBUG)
                .build())
        .build();

// Initialize Fabric with the debug-disabled Crashlytics
Fabric.with(this, crashlyticsKit, new Crashlytics()); // WRONG!

Instead use:

// Set up Crashlytics, disabled for debug builds
Crashlytics crashlyticsKit = new Crashlytics.Builder()
        .core(new CrashlyticsCore.Builder()
                .disabled(BuildConfig.DEBUG)
                .build())
        .build();

// Initialize Fabric with the debug-disabled Crashlytics
Fabric.with(this, crashlyticsKit); // Correct initializer!

Documentation: https://docs.fabric.io/android/crashlytics/build-tools.html#disable-crashlytics-for-debug-builds

In my case I was building app for android 4.4 compatibility which does not have build in Multidex support. I solved the problem by following steps bellow to enable Multidex for android 4.4 and the problem went away:
Enable multidex for apps with over 64K methods

David

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM