I have added following code to initialise there projects.
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:129574837465:android:0123456773a52cf4f6") // Required for Analytics.
.setApiKey("iubdeibneh8gzDt7Xn9f-jdjjdjdjdj") // Required for Auth.
.setDatabaseUrl("https://databasename-d7r7.firebaseio.com") // Required for RTDB.
.build();
FirebaseApp.initializeApp(context /* Context */, options, "secondary");
FirebaseOptions options2 = new FirebaseOptions.Builder()
.setApplicationId("1:129574837465:android:0123456773a52cf4f6") // Required for Analytics.
.setApiKey("iubdeibneh8gzDt7Xn9f-jdjjdjdjdj") // Required for Auth.
.setDatabaseUrl("https://databasename2-d7r7.firebaseio.com") // Required for RTDB.
.build();
FirebaseApp.initializeApp(context /* Context */, options2, "secondary2");
FirebaseOptions options3 = new FirebaseOptions.Builder()
.setApplicationId("1:129574837465:android:0123456773a52cf4f6") // Required for Analytics.
.setApiKey("kjdkj-o_3nk4jn4k3kjk23j") // Required for Auth.
.setDatabaseUrl("https://databasename3-d7r7.firebaseio.com") // Required for RTDB.
.build();
FirebaseApp.initializeApp(context /* Context */, options3, "secondary3");
After initialisation my app is running fine. I can use FirebaseAuth, and FirebaseRTDB just fine but it is throwing error when it has to access firebase_Application_Id for analytics.
I have cross checked the ids from google-services.json files of all the projects. I don't know why but it throws error saying:
Missing google_app_id. Firebase Analytics disabled.
I couldn't figure out the root of this error.
A Firebase project can have one or more Firebase Apps registered to it (for example, both the iOS and Android versions of an app, or both the free and paid versions of an app).
If you need to deactivate Analytics collection permanently in a version of your app, set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES (Boolean) in your app's Info.
In my case the problem was with incomplete Firebase configuration.
I was missing
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:4.3.3' // google-services plugin
}
}
allprojects {
...
repositories {
google()
}
}
from build.gradle.
And
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
from app/build.gradle.
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