Crashlytics found an invalid API key: null. after

2019-03-12 21:55发布

问题:

I had this bug after updated from com.google.gms:google-services:4.0.1 to com.google.gms:google-services:4.1.0

Crashlytics found an invalid API key: null. 
Check the Crashlytics plugin to make sure that the application has been added successfully! 
Contact support@fabric.io for assistance.

For Java projects, they hadn't this problem. I tried to invalidate cache and restart but not resolve.

I'm using: Android Studio 3.3 Canary 8

dependencies {
      classpath 'com.android.tools.build:gradle:3.3.0-alpha08'

      classpath 'com.google.gms:google-services:4.1.0'
      classpath 'io.fabric.tools:gradle:1.25.4'

      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.61"
      classpath "org.jetbrains.kotlin:kotlin-android-extensions:1.2.61"
}

FirebaseCrashlytics version:

implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

Thanks!

回答1:

Try adding this to manifest

<meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-xxxxxx~xxxxxx"/>

See my related answer to Default FirebaseApp is not initialized for more details.



回答2:

Try adding following dependency

implementation 'com.google.firebase:firebase-crash:16.2.1'


回答3:

In my case, the error was produced because I was picking the wrong APK file. You should pick the debug apk (app-debug.apk) instead of the app-name.apk.