Cannot resolve symbol default_web_client_id in Firebase's Android Codelab
Sometimes there is issue while parsing google-services.json
. I have reported this issue with to concerned team.
Meanwhile follow below step to fix this issue to get going further -
1) Open google-services.json
file -> client -> oauth_client -> client_id
2) Copy this client ID and hardcode this .requestIdToken("your ID")
It would allow to request "IdToken" via GoogleSignInAccount post successful google login and to authorize your credential with firebase.
EDIT
Try deleting and recreating the project and re-importing new google-service.json
in your Android project
A more generic solution would be to add the google-services.json
into the app's root directory.
And add
apply plugin: 'com.google.gms.google-services
at the end of build.gradle
file.
Explanation
When the app builds the key value pair strings from google-services.json
config file are then placed into the values.xml
file to make them globally available for use from anywhere in your code. This saves us from hard coding the client_id in your code.
Note
Do not add the default_web_client_id
with client_id
as its value in the strings.xml
in order to avoid the error of duplication, Error: Duplicate resources
later on when you run your code.
Apparently R.string.default_web_client_id
is generated from the IDE build
I had assumed we are supposed to manually add it - time consuming mistake
https://developers.google.com/android/guides/google-services-plugin
The google-services plugin has two main functions: 1) Process the google-services.json file and produce Android resources that can be used in your application's code.
~~~~
The main result of the JSON processing is to produce two XML files which you can reference as Android resources in your Java code.
And so - after successful build, if you search the IDE for string default_web_client_id
, you will see one result is values.xml under the /generated folder, and there it has the values for your firebase config, like the example below.
Actually seeing that file, helped to clarify things here
<resources>
<string name="default_web_client_id" translatable="false">123.apps.googleusercontent.com</string>
<string name="firebase_database_url" translatable="false">https://123.firebaseio.com</string>
<string name="gcm_defaultSenderId" translatable="false">123</string>
<string name="google_api_key" translatable="false">123</string>
<string name="google_app_id" translatable="false">123</string>
</resources>