Quickstart-android: Missing google_app_id

Created on 26 Mar 2018  路  5Comments  路  Source: firebase/quickstart-android

I'm following the guide here https://firebase.google.com/docs/configure/ to use multiple projects, one for dev and one for prod i've configured everything correct like the example provided

// Manually configure Firebase Options FirebaseOptions options = new FirebaseOptions.Builder() .setApplicationId("1:27992087142:android:ce3b6448250083d1") // Required for Analytics. .setApiKey("AIzaSyADUe90ULnQDuGShD9W23RDP0xmeDc6Mvw") // Required for Auth. .setDatabaseUrl("https://myproject.firebaseio.com") // Required for RTDB. .build();

Firebase works fine but I get this error for analytics "GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id."

How can I use two different analytics also for dev and prod? In the documentation it says

Google Analytics for Firebase collects events very early in the app start up flow, in some occasions before the primary Firebase app instance has been configured. In these cases, Firebase refers to the Android resource or GoogleService-Info.plist on iOS to look up the correct Google app ID to store events. For this reason, we recommend using the default configuration methods wherever possible.

but it's not clear to me. Should I always provide the production "google-services.json"?

Most helpful comment

Even when using FirebaseOptions to create a [DEFAULT] FirebaseApp, Google Service still tries to use google_app_id. This is a bug in my opinion.

The idea of using two strings.xml doesn't help if you want to change the id in runtime instead of creating flavors for each Firebase Project.

All 5 comments

@smoi the google-services.json is used at compile time to produce a strings.xml file through the google-services plugin:
https://developers.google.com/android/guides/google-services-plugin

That generated strings file will contain a string called google_app_id, which is read by a Content Provider that Firebase starts automatically.

You definitely _do not_ have to use the plugin and you're free to initialize FirebaseOptions manually. However if you want to take advantage of the automatic initialization, you could create two strings.xml files yourself (one for dev build, one for the prod build). If you use the right string names, it will behave exactly the same as if the google-services plugin had done it.

Even when using FirebaseOptions to create a [DEFAULT] FirebaseApp, Google Service still tries to use google_app_id. This is a bug in my opinion.

The idea of using two strings.xml doesn't help if you want to change the id in runtime instead of creating flavors for each Firebase Project.

I cannot even begin to understand how can you just blindly close a bug after referring to method of initialisation done by xml files.
It is obvious it IS a bug on side of Firebase initialisation.

The google_app_id should be taken from the configuration set in FirebaseOptions, there are people in this world that have a project with more than Release/Debug complexity (hint: flavors and dimensions).
Please take some time to prioritise this bug upwards and resolve it since it can cause various issues for devs that actually want to control the initialisation programatically.

This bug is not fixed and it still exists in 15 & 16 major releases

thank you for the link, also that bug is opened since Oct 9, 2018, that is impressive, I guess Firebase sdk initialization is not a critical feature

Was this page helpful?
0 / 5 - 0 ratings