Google sign in not working android?

 ̄綄美尐妖づ 提交于 2019-12-05 06:05:38
NezSpencer

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

  1. I went to my build.gradle(app), inside defaultConfig and changed the applicationId to my package name (I dont know why it wasnt 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) i.e after the dependencies

  2. I generated a new SHA-1 key. To generate SHA-1 key paste this in your terminal: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android then go to your credentials page and select your project.

  3. under OAuth 2.0 client, click your android client key. paste the SHA-1 key you generated and your package name as directed. click save.

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

Then try signing in again. Hopefully it should work. For more info, see this post and this as well. It helped me solve mine

You need to attach your android client key when creating GoogleSignInOptions like this

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!