Java – Google Login for Android – Release & Debugging

Google Login for Android – Release & Debugging… here is a solution to the problem.

Google Login for Android – Release & Debugging

So at the moment, I’m trying to implement Google login. I’ve followed the instructions on developer.android.com. I had a weird issue, I saw several people on SO talking about this, but it never got anywhere so I posted it here….

After generating the signed apk, I can log in using Google; If I don’t follow the method, I won’t be able to use Google login (i.e. if I plug in my phone and hit run on Android Studio, Google login tells me that my request turned out to be unsuccessful).

My questions are: 1) What the hell is going on here? and 2) How to use Google Sign in without having to generate a signed APK every time…

Update

I believe this is because the SHA-1 hash function either runs on debug keystore or on distro….

Solution

Sign your APK and use the SHA1 you signed to use Google services: For example, Gmail login…

So in this case, your debug SHA1 will not work.

The answer to the first question: I think your OAuth 2.0 client ID SHA1 is used for release builds. So in Debug mode it doesn’t work

Your second problem is that you can use Google login without generating a signed apk every time…

To do this, first find your debug SHA1

  1. Click the Gradle tab to the right of the View.
  2. Go to the ROOT folder -> Tasks -> android -> signingReport
  3. Double-click, this will build with signingReport and publish your SHA1 in your bottom View.

Go now

  1. https://console.developers.google.com

  2. Select the Credentials tab on the left

  3. At the bottom, select OAuth 2.0 Client ID, and then select Android Client 1

enter image description here

  1. Now change Release SHA1 to Debug SHA1 and save
  2. Now your Google login also works in Debug mode.

Note: During building the APK, change your build variant from Release to Debug

And during publishing, you must replace your publishing SHA1 in OAuth 2.0

Related Problems and Solutions