无法通过Google Provider登录求助(附Logcat异常及productFlavor信息)
Hey there, let's tackle this Google Sign-In issue you're hitting—since it worked previously and now throws that BadParcelableException, your product flavor setup is definitely a key angle to investigate. Let's break down the problem and actionable fixes:
Key Error Analysis
The critical log line here is:
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
This means the system can't locate the Google Sign-In configuration class during the login flow, which usually ties to missing ProGuard rules, mismatched flavor configurations, or dependency inconsistencies.
Step-by-Step Fixes
1. Sync ProGuard/R8 Rules Across All Flavors
Product flavors often have their own ProGuard settings, and it's easy to accidentally omit Google Sign-In's required rules for a specific flavor. Add these rules to your global proguard-rules.pro or each flavor's individual rules file:
# Keep Google Sign-In classes from being obfuscated -keep class com.google.android.gms.auth.api.signin.** { *; } -keep class com.google.android.gms.common.api.** { *; } -keep class com.google.android.gms.common.** { *; } -keep class com.google.android.gms.auth.** { *; }
Double-check that no flavor has stricter obfuscation rules that override these—some flavors might have minifyEnabled true without inheriting the base rules.
2. Validate google-services.json for Each Flavor
If you're using the Firebase/Google Services plugin, each product flavor needs its own google-services.json placed in src/<flavor-name>/google-services.json. Verify:
- The OAuth client ID matches the flavor's package name.
- The project ID and API keys are correct for that flavor's environment.
- Run
./gradlew cleanand rebuild the project to ensure the plugin generates the correct resources for your active flavor.
3. Ensure Consistent Dependencies Across Flavors
Mismatched Google Play Services Auth versions between flavors can cause classloader issues. Check your app-level build.gradle to make sure all flavors use the same dependency version:
// Add this in your dependencies block (ensure it's the same for all flavors) implementation 'com.google.android.gms:play-services-auth:20.7.0'
Avoid excluding or adding different versions of this dependency in specific flavor blocks—this creates conflicts that lead to missing classes.
4. Test with a Baseline Flavor
Switch to your debug flavor (or a minimal flavor that previously worked) and test Google Sign-In. If it works there, compare the problematic flavor's configuration:
- Check for differences in
build.gradle(e.g.,applicationId,signingConfig, dependency overrides). - Verify that the flavor's manifest doesn't have conflicting permissions or metadata entries for Google Sign-In.
5. Rule Out Network-Related Issues
While the ConnectivityService error might not be the root cause, unstable network can break the Sign-In flow. Confirm:
- Your app has the
INTERNETpermission inAndroidManifest.xml:<uses-permission android:name="android.permission.INTERNET" /> - The test device has a working internet connection (try accessing Google services in a browser to confirm).
Bonus Checks
- If you recently updated Google Play Services dependencies, try rolling back to the version that worked before—new versions sometimes introduce compatibility gaps with older device OS versions.
- Ensure the device's Google Play Services app is up-to-date (outdated versions can cause class loading failures).
内容的提问来源于stack exchange,提问作者Jean-Pascal MEWENEMESSE

