Android Studio同步项目遇Missing Google App Id报错(已含google-services.json)求助
Fixing "Missing Google App Id" Error When Syncing Android Project (With google-services.json Already Present)
Hey there, let’s work through this frustrating sync error together. Even though you’ve got the google-services.json file in your app directory, there are a few common issues that might be triggering the "Missing Google App Id" message. Here’s what to check:
1. Double-Check the google-services.json File
- Location: Ensure the file is directly in the app module’s root directory (not the project root, or subfolders like
src/main). If you use product flavors, place the corresponding config file in the flavor-specific folder (e.g.,app/src/devfor a "dev" flavor). - Validity: Open the file and look for the
mobilesdk_app_idfield—it should have a value formatted like1:1234567890:android:abcdef1234567890. If this field is missing or empty, you likely downloaded the wrong config file from Firebase. - Variant Match: If you have multiple build variants (debug/release or custom flavors), confirm you’re using the correct
google-services.jsonfor the variant you’re syncing. Re-download the config from Firebase specifically for that variant if needed.
2. Verify Gradle Configuration
- Project-Level Build.gradle: Make sure you’ve added the Google Services classpath in the
dependenciesblock of your project’s rootbuild.gradlefile:dependencies { classpath 'com.google.gms:google-services:4.4.0' // Use the latest stable version // Other classpath dependencies... } - App-Level Build.gradle: Confirm the Google Services plugin is applied. For older Gradle versions, add this at the bottom of the file:
For Android Gradle Plugin 7.0+, add it to theapply plugin: 'com.google.gms.google-services'pluginsblock instead:plugins { id 'com.android.application' id 'com.google.gms.google-services' // Add this line }
3. Clean, Rebuild, and Resync
- Run
Build > Clean Projectfrom the Android Studio menu, followed byBuild > Rebuild Project. - If that doesn’t work, manually delete the
.gradleand.buildfolders (both in the project root and app module), restart Android Studio, then sync your project again. This clears cached configuration that might be causing conflicts.
4. Confirm Firebase Project Association
- Check that your app’s package name exactly matches the one registered in your Firebase project (case-sensitive, though package names are typically lowercase).
- Ensure the app is still listed in your Firebase project—accidental removal would invalidate the config file.
If you work through these steps, one of them will almost certainly fix the sync error. Let me know if you hit any snags along the way!
内容的提问来源于stack exchange,提问作者Kapil Jindal
相关产品推荐
相关产品推荐

