skip to Main Content

Im trying to run this code:

gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();

but the R.string.default_web_client_id part isnt working (Cannot resolve symbol ‘default_web_client_id’).

i know that the ‘default_web_client_id’ string exists, but it isnt at the String XML, its in a generated ‘values.xml’

print of the values.xml and the path to it

am i doing something wrong or it should be working?

3

Answers


  1. you need to put it inside

    /app/src
    instead of
    /app/build folder
    else it won’t work because /app/build folder is a misc folder that contains files that are compiled when you build the apk

    Login or Signup to reply.
  2. I think your app will not going to crash anywhere. Just Android Studio’s IDE will produce that error. You can ignore that.

    Login or Signup to reply.
  3. I don’t understand that why not put the string into strings.xml? (app/src/main/res/values/strings.xml) or put it into a separate class that contains some constant variables.

    I use a class named Configs.java to save these variables.

    public class Configs {
        ... 
        public final static String WEB_CLIENT_APP_ID = "XXX"
        ... 
    }
    
    val options = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(Configs.WEB_CLIENT_APP_ID)
                    .requestEmail()
                    .build()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search