Below is the code I use to sign in to Google. I added the google-services.json file to the application folder. I am using classpath 'com.google.gms:google-services:2.0.0 ' in the gradle root directory. I checked my package on the developer console and its correct one and I added the SHA1 key, which I received by running the command keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android on the terminal (I using ubuntu). I have enabled the Google+ API. I created an OAuth consent screen and an OAuth client ID. Until I try to log in with google-
{statusCode = DEVELOPER_ERROR, resolution = null}
I am checking a similar question, but have not found a suitable solution. Code
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestProfile().requestId() .requestEmail().requestScopes(new Scope(Scopes.PLUS_ME)) .requestScopes(new Scope(Scopes.PLUS_LOGIN)) .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this ) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); googleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); } }); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); } } private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) {
manifest
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
source share