Every time I update my app's Firebase dependencies to anything more recent than the Feb. 27 2020 update, I start seeing this exception when I run my app:
04-29 18:21:58.170 3314 3541 E Firebase-Installations: Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: Failed to get FIS auth token
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.firebase.iid.zzt.zzb(com.google.firebase:firebase-iid@@20.1.6:54)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.firebase.iid.zzt.zza(com.google.firebase:firebase-iid@@20.1.6:72)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.firebase.iid.zzs.run(Unknown Source:12)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@17.1.1:6)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at java.lang.Thread.run(Thread.java:764)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: Caused by: com.google.firebase.installations.FirebaseInstallationsException
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.firebase.installations.FirebaseInstallations.doNetworkCall(com.google.firebase:firebase-installations@@16.2.2:350)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationInternal$0(com.google.firebase:firebase-installations@@16.2.2:323)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at com.google.firebase.installations.FirebaseInstallations$$Lambda$5.run(Unknown Source:4)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-29 18:21:58.177 3314 3543 E FirebaseInstanceId: ... 1 more
I've read several related questions and tried all of the following:
Here's the relevant parts of the project's build.gradle:
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.28.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
}
And the app's build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 23
targetSdkVersion 29
// ...
}
signingConfigs {
release {
// ...
}
}
buildTypes {
debug
release {
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-analytics:17.4.0'
implementation 'com.google.firebase:firebase-config:19.1.4'
implementation 'com.google.firebase:firebase-messaging:20.1.6'
implementation fileTree(dir: 'libs', include: ['PushIOManager-6.44.aar'])
// etc...
}
I left out the bundles, flavors, other dependencies, etc. but hopefully this is enough. I did have this in my Application class's onCreate method:
// Initialize Fabric with Crashlytics
Fabric.with(this, new Crashlytics());
// Initialize Firebase
FirebaseApp.initializeApp(this);
I took those out because I believe they're no longer needed. Regardless, it makes no difference. I've gone over the Firebase documentation several times and can't figure out what I'm missing.
Edit: one of the dependencies I originally left out was Responsys. As soon as I removed it from my app, I stopped seeing the errors. I'm waiting to hear back from their support team.
Firebase installation services (a new component used by Firebase Cloud Messaging) requires a valid Firebase combination options (specifically API key, Project ID, Application ID). Your app seems to have gotten an invalid combination along the way.
If you're initializing the app from a google-services.json
, download the latest version of that file for the app from the Firebase console, and re-include it in your project. Manually verifying the contents of this file is error prone, so I'd just make a backup copy of the current file and replace it with the one you downloaded.
If that doesn't solve the problem, reach out to Firebase support with the google-services.json
and other information for personalized help in troubleshooting.
Unfortunately, Google's frontend might incorrectly identify your API key as invalid. This can happen if your API key has not been used in a long time.
FirebaseInstallations
is new infrastructure for Firebase services that makes use of the API key that you initialize Firebase with. If you recently updated your Firebase SDKs, FirebaseInstallations
might have started using your API key which was not used before.
If you have issues with your API key, you can create a new API key in the Cloud Console:
APIs & Services
→ Credentials
+ CREATE CREDENTIALS
→ API key
In case you are using the google-services.json
config file from your Firebase Console, you first have to delete or restrict the API key used in your current google-services.json
in order to make Firebase update config file and use a new API key.
google-services.json
config file.Usage with this service
of your API key should show a number greater than 0.Application restrictions
to that API key by clicking the pencil symbol. !!Warning!! Do not delete an API key that existing installations of your applications require for other Firebase services like Firebase Auth or Realtime-Database.Wait a couple of minutes for Google servers to update. The next download of your google-service.json
config file should contain a new API key.
Other relevant links regarding API keys and the Firebase Installations API:
For me, all provided solutions didn't work: I upgraded all dependencies, imported a new google-services.json which was exactly the same. I had no API restrictions in the https://console.cloud.google.com/apis/credentials/ . Downgrading was not an options because of other dependencies.
What solved it for me was to set the Key restrictions in https://console.cloud.google.com/apis/credentials/ to "None".
Hope this helps someone.
If You are using a Real device
Check your Internet connection.
If you are using android studio Emulator
- Establish an internet connection by resetting the emulator.
2.1. Open Tools -> AVD manager
2.2. Wipe Data of the emulator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With