Skip to content

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)

gradle
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...
}
gradle
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 VersionAGP VersionGoogle Services Version
Iguana 2023.2.18.3.24.4.1
Electric Giraffe 2022.3.18.1.34.4.0
Electric Giraffe8.1.04.3.15
Electric Eel7.4.04.3.15
Dolphin7.3.14.3.14

Step-by-Step Fix

  1. Locate your project-level build.gradle file (usually in the android folder for Flutter projects or root directory for native Android projects)

  2. Update the dependencies block with compatible versions:

gradle
dependencies {
    classpath 'com.android.tools.build:gradle:8.3.2'
    classpath 'com.google.gms:google-services:4.4.1'
    // Other dependencies...
}
  1. Update the plugins block if present:
gradle
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
}
  1. Ensure the module-level build.gradle applies the Google Services plugin:
gradle
plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
    // Other plugins...
}
  1. Clean and rebuild your project:
bash
./gradlew clean
./gradlew build

Finding Current Versions

To find the latest compatible versions:

  1. Check the official Google Services Plugin documentation
  2. 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:

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:

xml
<preference name="GradlePluginGoogleServicesEnabled" value="true" />
<preference name="GradlePluginGoogleServicesVersion" value="4.4.1" />

Additional Troubleshooting

If updating versions doesn't resolve the issue:

  1. Clean your project: Delete .gradle and .idea directories, then rebuild
  2. Invalidate caches: Use Android Studio's "File > Invalidate Caches / Restart" option
  3. 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.