如何修复这个 CrashlyticsMissingDependencyException?

我已经使用最新的 Crashlytics (面料集成)有一段时间了。但是最近由于缺少依赖性,我遇到了以下崩溃错误,尽管我没有改变 Crashlytics 配置的任何内容。

知道吗?

02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     |  |
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     |  |
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     |  |
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .   \ |  | /
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .    \    /
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     \  /
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .      \/
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ 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.
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .      /\
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     /  \
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .    /    \
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .   / |  | \
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     |  |
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     |  |
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .     |  |
02-08 22:18:00.935  18887-18887/? E/Fabric﹕ .
02-08 22:18:00.935  18887-18887/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.android.staging, PID: 18887
java.lang.RuntimeException: Unable to create application com.example.android.App: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: com.crashlytics.android.CrashlyticsMissingDependencyException:
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.handleBindApplication(ActivityThread.java:4734)
at android.app.ActivityThread.access$1600(ActivityThread.java:171)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5506)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
26095 次浏览

The only workaround for now, if you really need to publish your app, is to change the dynamic version numbers to static ones:

[...]


classpath 'io.fabric.tools:gradle:1.14.4'


[...]


compile('com.crashlytics.sdk.android:crashlytics:2.2.0@aar') {
transitive = true
}


[...]

EDIT:

an updated version of the Fabric SDK has been published; you can get it by changing the line to this:

classpath 'io.fabric.tools:gradle:1.26.1'

Seems like specifying the plugin version as:

classpath 'io.fabric.tools:gradle:1.+'

picks up 1.15.1, which has the problem.

Specifying major and minor to previous 1.14 seems to be stable:

classpath 'io.fabric.tools:gradle:1.14.+'

Mike from Crashlytics here. We shipped an updated version - 1.15.2 - earlier today that includes a fix for this behavior. If you run:

./gradlew assemble --refresh-dependencies

that will pull in the latest version. You can also see more details on the fix here.

I have added the following codes before I actually installed Fabric/Crashlytics:

debug {
ext.enableCrashlytics = false
}

Removing it before the first run with Crashlytics solved the problem. The problem no longer occurs after the first run.

In case this helps someone else, I had a similar issue when upgrading Crashlytics to Fabric. In my case, the plugin left 2 lines from Crashlytics that I needed to manually remove before it would work.

In the gradle file, under buildscript dependencies, I had to manually remove:

classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.16.0'

Also, under dependencies, I had to manually remove:

compile 'com.crashlytics.android:crashlytics:1.1.13'

I had same problem after update plugin. to solve need remove from AndroidManifest.xml:

<meta-data
android:name="com.crashlytics.ApiKey"
android:value="API_SECRET_KEY" />

and add to fabric.properties:

apiSecret=API_SECRET_KEY
apiKey=YOUR_SECRET_KEY

UPDATE:

Now, you have to use:

  <meta-data
android:name="io.fabric.ApiKey"
android:value="API_KEY" />

For me it was because of dataBinding = true. Upgrading the fabric gradle plugin to 1.21.0 fixed the issue: https://twittercommunity.com/t/fabric-gradle-plugin-1-21-0-add-support-for-android-databinding-true/57474

I had this commented out in gradle

apply plugin: 'io.fabric'

needed to uncomment it

Or if you don't have it, add it!

If you are using the disable function during debug as shown

 Crashlytics crashlyticsKit = new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
.build();
Fabric.with(this, crashlyticsKit);

What happens when you update the version of crashlytics is that

Fabric.with(this, crashlyticsKit);

is turned to

Fabric.with(this,new Crashlytics());

So make sure to change that back to crashlyticskit. If you are doing this correctly and the error still appears then make sure you have

debug {


ext.enableCrashlytics = false
}

under android {buildtypes{}}

Fix for me From official source

Disable Crashlytics for Debug Builds

If you don’t need Crashlytics crash reporting or beta distribution for debug builds, you can safely speed up your debug-builds by disabling the plugin entirely with these two steps:

First, add this to your app’s build.gradle:

android {
buildTypes {
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
...

Next, disable the Crashlytics kit at runtime. Otherwise, the Crashlytics kit will throw the following error:

com.crashlytics.android.core.CrashlyticsMissingDependencyException:


This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up`

You can disable the kit at runtime for debug builds only with the following code:

// 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);

Check if crashlytics is disabled in build.gradle file

    debug {
ext.enableCrashlytics = false
}

Instead use

    debug {
ext.enableCrashlytics = true
}

May be I am late to reply. But this can happen from one more reason apart from all the above answers

If you miss to add

apply plugin:'io.fabric'

This may seem strange but this will result in the same issue

This is by default added by fabric when we sign up and add code from the Fabric window Using IDE but accidentally it can be deleted.

The issue also occurs if you accidentally include the Crashlytics BuildConfig - very easy to do with Android Studio/IntelliJ auto-imports.

I'd imported

import com.crashlytics.android.core.BuildConfig;

Instead of my own

import <package_name>.BuildConfig;

Make sure to add apply plugin: 'io.fabric' into your application project build.gradle. In my case, I had a common build.gradle with apply plugin: 'io.fabric'. Moving it to application project solved the problem.

In my case, I was using fabric in a "CommonLib" module that was added as a dependency in all other modules (including app). So, I had added apply plugin: 'io.fabric' after buildscript {} block. So, I placed two plugins together:

apply plugin: 'com.android.library'
apply plugin: 'io.fabric'

And problem got solved!

Removing the application icon fixed Crashylitics, whaaat?

I had everything done based on the onboarding tutorial, using the latest versions, etc.

Just wasted an hour trying to figure this out. It turns out someone thought it was a good idea to read the package name of the application icon instead of context.packageName to get the application's resources given a context. It's done in this method:

io.fabric.sdk.android.services.common.CommonUtils#getResourcePackageName

This obviously blows up if you happen to use an icon that's not inside the APK, for example: android:icon="@android:drawable/sym_def_app_icon". It probably was a good idea at the time, wonder what weird bug they were trying to work around?!

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

Add that to in AndroidManifest.xml.