Fixing :app:mapDebugSourceSetPaths
Error with Google Services Plugin
When working with Android projects that use Firebase or other Google services, you may encounter a build error related to the mapDebugSourceSetPaths
task that prevents your app from compiling. This error typically occurs due to version incompatibility between the Android Gradle Plugin (AGP) and the Google Services plugin.
Problem Overview
The error message typically appears as:
Execution failed for task ':app:mapDebugSourceSetPaths'
> Error while evaluating property 'extraGeneratedResDir' of task ':app:mapDebugSourceSetPaths'
> Querying the mapped value of provider(java.util.Set) before task ':app:processDebugGoogleServices' has completed is not supported
This indicates a version mismatch between your Android Gradle Plugin and the Google Services plugin, where newer versions of AGP require specific compatible versions of the Google Services plugin.
Common Pitfall
Simply removing the Google Services plugin to fix the build (as some outdated solutions suggest) will break Firebase functionality. The correct approach is to find compatible versions that work together.
Solution: Version Compatibility
The most reliable solution is to ensure you're using compatible versions of both the Android Gradle Plugin and Google Services plugin. Here are the currently recommended version combinations:
Latest Stable Combinations (April 2024)
plugins {
id 'com.android.application' version '8.3.2' apply false
id 'com.android.library' version '8.3.2' apply false
id 'com.google.gms.google-services' version '4.4.1' apply false
}
dependencies {
classpath 'com.google.gms:google-services:4.4.1'
// Other dependencies...
}
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
// Other plugins...
}
Previous Compatible Versions
For reference, here are version pairs that have worked with specific Android Studio releases:
Android Studio Version | AGP Version | Google Services Version |
---|---|---|
Iguana 2023.2.1 | 8.3.2 | 4.4.1 |
Electric Giraffe 2022.3.1 | 8.1.3 | 4.4.0 |
Electric Giraffe | 8.1.0 | 4.3.15 |
Electric Eel | 7.4.0 | 4.3.15 |
Dolphin | 7.3.1 | 4.3.14 |
Step-by-Step Fix
Locate your project-level
build.gradle
file (usually in theandroid
folder for Flutter projects or root directory for native Android projects)Update the dependencies block with compatible versions:
dependencies {
classpath 'com.android.tools.build:gradle:8.3.2'
classpath 'com.google.gms:google-services:4.4.1'
// Other dependencies...
}
- Update the plugins block if present:
plugins {
id 'com.android.application' version '8.3.2' apply false
id 'com.android.library' version '8.3.2' apply false
id 'com.google.gms.google-services' version '4.4.1' apply false
}
- Ensure the module-level
build.gradle
applies the Google Services plugin:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
// Other plugins...
}
- Clean and rebuild your project:
./gradlew clean
./gradlew build
Finding Current Versions
To find the latest compatible versions:
- Check the official Google Services Plugin documentation
- Visit the Play Services Plugins GitHub repository for compatibility information
Special Cases
Flutter Projects
For Flutter projects, the fix is applied in android/build.gradle
:
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.2'
classpath 'com.google.gms:google-services:4.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Cordova Projects
For Cordova, add these preferences to your config.xml
:
<preference name="GradlePluginGoogleServicesEnabled" value="true" />
<preference name="GradlePluginGoogleServicesVersion" value="4.4.1" />
Additional Troubleshooting
If updating versions doesn't resolve the issue:
- Clean your project: Delete
.gradle
and.idea
directories, then rebuild - Invalidate caches: Use Android Studio's "File > Invalidate Caches / Restart" option
- Check for other conflicts: Ensure you don't have conflicting version declarations in different configuration files
Pro Tip
Always check for the latest version compatibility when updating Android Studio or Gradle plugins. The Google Services plugin page is regularly updated with current supported versions.
Conclusion
The :app:mapDebugSourceSetPaths
error is typically resolved by ensuring version compatibility between the Android Gradle Plugin and Google Services plugin. Rather than removing essential plugins, focus on finding the correct version combinations that work with your development environment. Regularly checking the official documentation will help prevent these compatibility issues in the future.