Firebase谷歌认证异常:Android应用登录遇ApiException:10错误求助
ApiException: 10 on Android Hey there, I’ve wrestled with this exact com.google.android.gms.common.api.ApiException: 10: error more times than I can recall—it’s so frustrating when you’ve followed every step in the docs and still hit a wall! Let’s walk through the most common (and easy-to-miss) fixes that might resolve your issue:
Double-check all SHA1 (and SHA-256) fingerprints in Firebase
Don’t just stop at your debug SHA1—if you’re testing a release build, or using a custom debug keystore, make sure all fingerprints for the builds you’re running are added to your Firebase project. You can grab the correct debug fingerprint with this command:keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass androidFor release builds, swap in your production keystore path, alias, and credentials. Also, add the SHA-256 fingerprint too—modern Google Sign-In requires it for some flows.
Validate OAuth 2.0 clients in Google Cloud Console
Firebase syncs with Google Cloud under the hood, so head over to the Cloud Console linked to your Firebase project. Navigate to APIs & Services > Credentials and verify:- There’s an Android OAuth client ID with the exact SHA1 fingerprint you added to Firebase.
- A Web OAuth client ID exists (yes, even for pure Android apps—some SDK dependencies rely on this).
Replace your
google-services.jsonand rebuild
Every time you update fingerprints or OAuth settings, you need to download a freshgoogle-services.jsonfrom Firebase and replace the one in your app’s root directory. After replacing, clean and rebuild your project:./gradlew clean && ./gradlew assembleDebugThis clears any cached config that might be stuck using old settings.
Confirm your package name is a perfect match
Even a tiny typo in your package name (capitalization, extra character) between Firebase and yourAndroidManifest.xmlwill break authentication. Double-check that the package name in Firebase’s app settings matches exactly what’s in your manifest’spackageattribute.Test on a fresh device/emulator
Old cached Google account data or app preferences can mess with the sign-in flow. Try testing on a brand-new emulator, or clear your app’s data/storage on your test device before trying again.Ensure the Google Sign-In API is enabled
While Firebase usually enables this automatically, it’s worth confirming. In the Google Cloud Console’s APIs & Services > Library, search for "Google Sign-In API" and make sure it’s marked as enabled.
If you’ve tried all these and still see the error, check your Logcat for more detailed error messages—sometimes there’s a hint about a missing scope or misconfigured client that the generic ApiException:10 doesn’t reveal.
内容的提问来源于stack exchange,提问作者Abdullah Muhammad

