So currently, I am trying to implement google sign-in .. I have followed the instructions on developer.android.com .. I am having a weird issue and I see several people on SO talk about this but it never gets anywhere so I am posting this here ...
I am able to use google sign in AFTER I generate a signed apk; and if I don't follow that method I am not able to use google sign in (i.e if I plug my phone in and hit run on android studio, google sign in tells me my request result was unsuccessful)
My question is 1) Whats really going on here? and 2) How can I use google sign in without needing to generate a signed apk each time ..
UPDATE
I believe it is because of the SHA-1 hash function that is either run on the debug keystore vs release ...
Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.
By default on gradle, the commands assembleDebug and installDebug build the application in debug mode. Android Studio signs your app in debug mode automatically when you run or debug your project from the IDE. An APK built by commands assembleRelease and installRelease is by default in release mode.
Debugging allows you to go through each line of code, evaluating your app's variables, methods and how well your code is working. It's easier to find small mistake in large pieces of code. In this article we will go through basic tips and tricks on debugging an Android app.
After signing your apk is using your signed SHA1 for using google services..like gmail login..
so your debug SHA1 will not work..in this case.
Answer to your first question..i think your OAuth 2.0 client IDs SHA1 is for release version. so in debug mode it is not working
And your second question yes you can use google sign in without generating signed apk each time..
For this first find your debug SHA1
Now go to
https://console.developers.google.com
select credential tab on leftside
select OAuth 2.0 client IDs at bottom and select Android client 1
N.B: during build apk change your Build variant from release to debug
And during release you have to replace back your release SHA1 in the OAuth2.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With