Skip to content

Missing google_app_id #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smoi opened this issue Mar 26, 2018 · 5 comments
Closed

Missing google_app_id #458

smoi opened this issue Mar 26, 2018 · 5 comments

Comments

@smoi
Copy link

smoi commented Mar 26, 2018

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"?

@samtstern
Copy link
Contributor

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

@tsuharesu
Copy link

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.

@originx
Copy link

originx commented Mar 22, 2019

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

@samtstern
Copy link
Contributor

@originx the bug is tracked here:
firebase/firebase-android-sdk#66

@originx
Copy link

originx commented Mar 23, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants