问题
I developed a app with Flutter and tested on my device using the command:
flutter run --release
and everything worked fine. I also tried building the app with:
flutter build apk --release
and installing it manually, and still everything was ok.
I uploaded on the store, and now the login doesn't work anymore.
I tried looking at the logcat and the error i get when i try to login is:
I/flutter: exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null)
I tried adding the appCompat dependency and I checked the the SHA1 keys, everything is in the right place, I can't figure out why when I download if from the store it doesn't work anymore.
回答1:
Your app probably does not have the correct Google credentials for the Token API.
When you first signed up on the Google Play Console, you probably opted into Google's app signing service. What this does is, after you sign your app with your keystore and upload it to the Play Console, Google will actually sign your app with a generated keystore and roll that version out. You can access the keys with which the release version is signed from the console, under Release Management -> App signing -> App signing certificate.
Once you locate the certificate, you need to use the SHA1 key, and generate a new Android Oauth Credential, and then add that to your google-services.json. If you are not using Firebase, you will have to add the Oauth credential to your backend as well.
If you look at HarshitG's answer on this Android thread concerning the same issue, you can see a picture of where you can get the certificate information on the Play Console.
google signIn not working in release mode apk android
来源:https://stackoverflow.com/questions/53263246/google-sign-in-doesnt-work-after-release-of-flutter-app