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'
am i doing something wrong or it should be working?
CodePudding user response:
I think your app will not going to crash anywhere. Just Android Studio's IDE will produce that error. You can ignore that.
CodePudding user response:
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
CodePudding user response:
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()