Google does not work on Android version

I have a problem with my current application. My OAuth2.0 SHA1 is correct and is created from the release version key store file. My problem is that I get resultCode = 0 every time on onActivityResult. I print out the intent value and get the following: googleSignInStatus = Status {statusCode = INTERNAL_ERROR, resolution = null} But, if I run it in debug mode, the login works fine, and for this case, the intent value is: googleSignInAccount = com.google.android.gms .auth.api.signin.GoogleSignInAccount @ 31976389]

Does anyone know how to solve this problem. NOTE. Somewhere I found one message that they recommend putting in the email address and project name on the OAuth contest screen; I already tried this and still did not work.

0
android google-oauth2 google-signin
Apr 07 '16 at 10:37
source share
1 answer

Obviously, first check that your sha1 key is correct for release. But the problem here was different. I am using new google play services (iecompile 'com.google.android.gms: play-services: 8.4.0'). And the problem can be solved by changing the GoogleSignInOption object. Instead:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestIdToken("YOUR_WEB_API_ID.apps.googleusercontent.com") .build(); 

I use:

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN)) .requestScopes(new Scope(Scopes.PLUS_ME)) .requestEmail() .build(); 

This solves the error returning statusCode = INTERNAL_ERROR. You can then use this gso object to create a GoogleApiClient, as shown below:

  mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API,gso) // .addApi(Plus.API, null) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) // .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); 
+1
Apr 12 '16 at 14:13
source share



All Articles