You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio无法识别GoogleServicesPlugin及Gradle报错求助

Fixing "No such property: config for class: com.google.gms.googleservices.GoogleServicesPlugin" Error

Hey there, I’ve run into this exact frustrating issue before, so let’s break down what might be going wrong and how to fix it, even after the standard troubleshooting steps you’ve already tried.

First, let’s recap your scenario to make sure we’re on the same page:

  • Randomly getting the No such property: config for class: com.google.gms.googleservices.GoogleServicesPlugin error
  • Android Studio can’t resolve com.google.gms.googleservices.GoogleServicesPlugin (shows "cannot resolve symbol" in your app-level build.gradle)
  • You’ve already tried updating google-services, adding jcenter(), invalidating caches/restarting, updating Gradle/AS, reinstalling SDKs, etc.

Here are targeted fixes to try next:

1. Fix Version Compatibility Between AGP and Google Services Plugin

Your current setup uses AGP 4.1.1 with google-services 4.3.4—these versions might not play nicely together. AGP 4.x requires a specific range of google-services versions to avoid reflection-related errors like this one.

Try updating your google-services plugin to a version confirmed compatible with AGP 4.1.1:

// In your project-level build.gradle
dependencies {
    classpath 'com.android.tools.build:gradle:4.1.1'
    // Update to this compatible version
    classpath 'com.google.gms:google-services:4.3.10'
}

If that doesn’t work, consider upgrading AGP to the latest stable version in the 4.x series (4.2.2) alongside matching Gradle and google-services versions:

  • AGP 4.2.2 requires Gradle 6.7.1
  • Pair it with google-services 4.3.10

2. Double-Check Plugin Application Order

The google-services plugin has strict placement rules:

  • In project-level build.gradle: Always declare com.google.gms:google-services after com.android.tools.build:gradle (you already have this right, but double-check no changes messed it up)
  • In app-level build.gradle: Apply the google-services plugin last, after all other plugins and the android {} block. For example:
// App-level build.gradle
plugins {
    id 'com.android.application'
    // Other plugins (like Firebase, crashlytics) go here
}

android {
    // Your android config
}

dependencies {
    // Your dependencies
}

// This must be the LAST line in the file
apply plugin: 'com.google.gms.google-services'

3. Perform a Deep Clean & Dependency Refresh

Sometimes the standard Invalidate Caches isn’t enough. Let’s wipe all cached data completely:

  • Close Android Studio
  • Delete the .gradle folder in your project root directory
  • Delete the .gradle folder in your user home directory (e.g., ~/.gradle on macOS/Linux, C:\Users\<YourName>\.gradle on Windows)
  • Delete the build folders in both your project root and app module
  • Reopen Android Studio, click "Sync Project with Gradle Files" and wait for the full sync to complete

4. Check for Conflicting Plugins or Duplicate Dependencies

If you’re using other Google/Firebase plugins (like com.google.firebase.crashlytics), make sure their versions are aligned with google-services. Also, ensure you don’t have duplicate declarations of google-services anywhere in your project (e.g., in multiple modules or imported via another dependency).

5. Verify Repository Priority

In your project-level build.gradle, ensure google() is listed before other repositories. This ensures Android Studio pulls the correct version of google-services from Google’s repository first, not a stale version from jcenter or mavenCentral:

// Project-level build.gradle
repositories {
    google() // Must come first
    jcenter()
    mavenCentral()
}

Give these steps a try one by one—usually the version compatibility or deep clean fixes this stubborn issue for me. Let me know if any of these work for you!

内容的提问来源于stack exchange,提问作者DAL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:23:33