Google not working on Android?

So, the problem that my project ran into is that google login doesn't work sequentially. That is, it works for my friend, and not for me from my computer, although yesterday he worked for me before wiping my phone (the phone is damaged). Our login code is the standard for google login, and the problem is that the result continues to return false, I think. code:

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome_screen); findViewById(R.id.sign_in_button).setOnClickListener(this); GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button); signInButton.setSize(SignInButton.SIZE_STANDARD); signInButton.setScopes(gso.getScopeArray()); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.sign_in_button: signIn(); break; } } private void signIn() { Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); } public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); } } private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); // mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName())); updateUI(acct); } else { // Signed out, show unauthenticated UI. noUpdateUI(); } } private void updateUI(GoogleSignInAccount acct) { Intent intent = new Intent(getApplicationContext(), HomeScreen.class); Bundle bundle = new Bundle(); bundle.putSerializable("NEW_USER", new ClientUser(acct)); intent.putExtras(bundle); startActivity(intent); } For some reason, the result is false: private void noUpdateUI() { System.out.println("**** Try again****"); // mStatusTextView.setText(R.string.signed_out); findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE); } 

I think I correctly configured the credentials of my application, as it worked previously from my desktop before I wiped my phone. Note that my friend had the same problem as his laptop, but he has no problem with his desktop. Not sure what happened; any suggestions?

Log from sys.out:

 12-16 18:48:43.282 27375-27375/oose2017.place2b D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN 12-16 18:48:43.412 27375-27375/oose2017.place2b I/Timeline: Timeline: Activity_launch_request id:oose2017.place2b time:3231784 12-16 18:48:43.452 27375-27375/oose2017.place2b D/Activity: performCreate Call Injection manager 12-16 18:48:43.462 27375-27375/oose2017.place2b I/InjectionManager: dispatchOnViewCreated > Target : com.google.android.gms.auth.api.signin.internal.SignInHubActivity isFragment :false 12-16 18:48:43.462 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* installDecor mIsFloating : false 12-16 18:48:43.462 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* installDecor flags : 8454400 12-16 18:48:43.462 27375-27375/oose2017.place2b D/SecWifiDisplayUtil: Metadata value : SecSettings2 12-16 18:48:43.472 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null 12-16 18:48:43.472 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* isFloatingMenuEnabled return false 12-16 18:48:43.482 27375-27375/oose2017.place2b D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! 12-16 18:48:43.492 27375-27584/oose2017.place2b D/mali_winsys: new_window_surface returns 0x3000, [1440x2560]-format:1 12-16 18:48:43.542 27375-27375/oose2017.place2b I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@174719e3 time:3231916 12-16 18:48:43.962 27375-27375/oose2017.place2b V/ActivityThread: updateVisibility : ActivityRecord{1458bd29 token=android.os.BinderProxy@e9978a8 {oose2017.place2b/oose2017.place2b.interfaces.Welcome.WelcomeScreen}} show : true 12-16 18:48:43.962 27375-27375/oose2017.place2b V/ActivityThread: updateVisibility : ActivityRecord{d3e4299 token=android.os.BinderProxy@174719e3 {oose2017.place2b/com.google.android.gms.auth.api.signin.internal.SignInHubActivity}} show : true 12-16 18:48:48.102 27375-27375/oose2017.place2b I/System.out: ***** Try again!***** 12-16 18:48:48.132 27375-27375/oose2017.place2b I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@e9978a8 time:3236507 
+5
source share
3 answers

I had the same problem. I solved this by doing the following:

  • I went to my build.gradle (application), inside defaultConfig, and changed applicationId to my package name (I don’t know why it was not the same initially). I switched from compile 'com.google.android.gms:play-services-auth:8.3.0' to compile 'com.google.android.gms:play-services-auth:8.4.0' Make sure apply plugin: 'com.google.gms.google-services' is at the bottom of your build.gradle (app) ie file after the dependencies

  • I created a new SHA-1 key. To generate the SHA-1 key, paste it into the terminal: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android then go to the credentials page and select your project.

  • under the OAuth 2.0 client, click your android client key. insert the SHA-1 key that you created and the name of your package as directed. Click "Save."

    1. download the new google-services.json file and paste it into your app / directory.

Then try logging in again. Hope this works. For more information see this post and. This helped me solve my problem.

+8
source

When creating GoogleSignInOptions, you need to attach your Android client key. like this

  signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN). requestScopes(new Scope(Scopes.EMAIL)). requestEmail(). requestIdToken(getString(R.string.client_id)). build(); 
0
source

I had to downgrade from play-services-auth 16.0.0 to

 implementation 'com.google.android.gms:play-services-auth:15.0.1' 

And then it worked.

0
source

Source: https://habr.com/ru/post/1238441/


All Articles