I am trying to learn Firebase, so I went through the Android Codelab. The project they gave me however, had an error:
Cannot resolve symbol default_web_cl
Download again google-services.json file from the firebase project that you connected with your android project and replace it in app/src directory. And then select clean project option which is in build sub menu. This worked for me.
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.
**The main issue with this right now for me was to make sure to download the json file from the same location. If the initial one came from the firebase console do not use the api console to get the file, and vise versa. The files are not the same **
Fixed after using this link to create my backend id to Google API.
https://developers.google.com/identity/sign-in/android/start-integrating#get_your_backend_servers_oauth_20_client_id
1- Open the Credentials page in the API Console.
2- The Web application type client ID is your backend server's OAuth 2.0 client ID.
After this, you can re-download your json file and android studio will automatically matching your string id.
I also had the same issue, make sure "google-services.json" is in your app directory. Then simply rebuild the project from "Build -> Rebuild Project"
Since the string resource "default_web_client_id" is auto-generated, it will be resolved once you rebuild the project
I already have google-services.json
downloaded and parsed, but still it doesn't find the string.
I noticed that my oauth_client
had a key with client_type of 1
and that's all. In the Google API console, I only had an Android key.
So, you need to go to the API console and generate a Web Server
key. Then, download your google-services.json again, and you'll have a oauth_client
with a type of 3.
Now, the plugin will generate a string called default_web_client_id.