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.
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.