简体   繁体   中英

Why doesn't my deployed Android app sign into Google Play Services, while my debug app does?

My Android app's login to Google Play Games services seems to fail silently: after choosing the user in the sign-in activity, onActivityResult() receives a resultCode value of 10002. The Android APIs deposit these messages in the logcat:

W/SignInActivity(16216): onSignInFailed()...
W/SignInActivity(16216): Sign in failed during 6
W/SignInActivity(16216): ==> Returning non-OK result: 10002

while Log.w() commands I placed in onActivityResult() deposit these messages:

W/Main activity(16167): In activity result with code 10002
W/Main activity(16167): activity result requests sign in
W/Main activity(16167): unsolved resolution

The strange thing is that it used to work, and when I try to debug it from Android Studio, login works perfectly every time , so I can't even debug the app!

Where can I get started debugging this?

I found the solution thanks to a problem with the same error but a completely different cause , but this situation is different in that it was caused by activating a feature in the Google Play Developer Console.

The keys to this particular error are that:

  1. The production app used to work properly, but doesn't any more.
  2. The debug version still works properly.

Back in May, Google introduced a feature wherein they sign your app in the Play Store . My original app was signed with the certificate generated by Android Studio, but Google seems pretty gung-ho about their signing so I switched to that without reading the fine print very carefully. As a result:

  • For the debug app, the Google Play Games API expected the debug certificate, and Android Studio still used that certificate to generate a debug apk, so the Games API routinely accepted sign-in while debugging.
  • For the production app, the API expected the Android Studio-generated production certificate, which Android Studio happily supplied, but Google Play replaced with its own certificate, so the Games API routinely rejected sign-in.

The solution is to:

  • stop cursing;
  • visit the App signing option under Release management in the usual Play Store developer Console ;
  • copy the SHA-1 fingerprint under "App signing certificate" ( not the fingerprint "Upload certificate" -- that's what got you into this mess);
  • visit the Credentials page at Google's site for developers
  • select your app
  • paste the certificate you just copied into the text field labeled "Signing-certificate fingerprint." (The field itself is below some instructions on how to extract it from your keystore -- don't use those instructions when Google signs your app!)

At this point the deployed version worked for me like magic. No programming required!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM