Search code examples
androidfirebasefirebase-analyticsmultiple-projects

I am using multiple firebase projects in an Android App. I am getting this error : Missing google_app_id. Firebase Analytics disabled


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.


Solution

  • Could you double check if google-services.json is located at your Android app module root directory?

    enter image description here

    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",
              ...
            }
         }
       ]
     }