I am using multiple firebase projects in an Android App. I am getting this error : Missing google_app_id. Firebase Analytics disabled
Solution 1
Could you double check if google-services.json is located at your Android app module root directory?
If it is there, make sure google-services.json has the mobilesdk_app_id key. It should be located under the client_info node.
{
...,
"client": [
{
"client_info": {
"mobilesdk_app_id": "random_string",
...
}
}
]
}
Solution 2
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.
Solution 3
The issue could be due to instant app
being enabled
Solution : Manually add google_app_id to the strings.xml file — as told here
Update : In case app crashes without any warning or error, try this (maven):
Go to project level build.gradle
& check if it looks exactly like this:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
and the code suddenly works and when you'll look at other answers you will find the same.
Solution 4
Initialize FirebaseApp early in OnCreate() using APP ID and Client key:
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:530266078999:android:481c4ecf3253701e") // Required for Analytics.
.setApiKey("AIzaSyBRxOyIj5dJkKgAVPXRLYFkdZwh2Xxq51k") // Required for Auth.
.setDatabaseUrl("https://project-1765055333176374514.firebaseio.com/") // Required for RTDB.
.build();
FirebaseApp.initializeApp(this /* Context */, options, "secondary");
Solution 5
@Anton Malyshev 's answer is correct.
↓ project gradle
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:4.3.3' // google-services plugin
}
}
allprojects {
...
repositories {
google()
}
}
↓ app gradle
apply plugin: 'com.google.gms.google-services'
mark922
Updated on June 17, 2022Comments
-
mark922 about 2 years
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.
-
Oussema Aroua over 7 yearsredownload the google-services.json again and rebuild your project
-
mark922 over 7 yearsI did that. It is not working !
-
ericn about 7 yearsThe docs say "Note: On Android and iOS, Firebase Analytics are only logged for the default app." firebase.google.com/docs/configure, have you check that?
-
Sethuraman Srinivasan over 3 years@mark922 Have you found a solution for this issue?
-
-
mark922 over 7 yearsYes. I cross checked it again. It is in the proper location and "mobilesdk_app_id":"VALUE" is also there.
-
mark922 over 6 yearsThe main problem was I wanted to initialise the default firebase project programmatically. I have to use at least one google-services.json file to initialise the default project. Here is how the firebase initialises itself : How does Firebase initialize on Android?.
-
gregn3 about 4 yearsThanks!
// ADD THIS AT THE BOTTOM
also works at the top. Fixed it for me.