'firebase-crashlytics-gradle plugin fails with exception 'googleServicesResourceRoot' doesn't have a configured value

After applying the crashlytics plugin 'com.google.firebase.crashlytics' to my project, my build fails with an exception:

// build.gradle.kts
buildscript {
    repositories {
        google()
    }
    dependencies {
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.7.1")
    }
}

apply(plugin = "com.google.firebase.crashlytics")
$ ./gradlew

...

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':platforms:mobile:android:app:uploadCrashlyticsMappingFileCglDevRelease' (type 'UploadMappingFileTask').
  - In plugin 'com.google.firebase.crashlytics' type 'com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask' property 'googleServicesResourceRoot' doesn't have a configured value.
    
    Reason: This property isn't marked as optional and no value has been configured.
    
    Possible solutions:
      1. Assign a value to 'googleServicesResourceRoot'.
      2. Mark property 'googleServicesResourceRoot' as optional.

How can I avoid this gradle exception without using the google-play-services plugin and still have a successful obfuscation mapping uploaded to firebase crashlytics?

What is the firebase-crashlytics-gradle plugin expecting from googleServicesResourceRoot? Build flavor resources root? The directory where the google-services.json file is located at? (which I don't use)?

I found Type 'UploadMappingFileTask' property 'googleServicesResourceRoot' doesn't have a configured value, with the same root cause and an accepted solution, which is to apply the google-play-services plugin prior to the crashlytics plugin.

However, we are not using the google-play-services plugin and we don't intend to do it in the future.



Solution 1:[1]

We're also not using the google services plugin and were getting this error.

For each flavor that we want to connect to Firebase and Crashlytics we have an xml resource file named values.xml containing the required Firebase properties (project_id, google_app_id, google_crash_reporting_api_key, etc) in the resource files values folder (e.g. app/src/prodRelease/res/values/values.xml).

In the app level build.gradle.kts we have:

project.afterEvaluate {
    tasks.withType<UploadMappingFileTask> {
        val myDirProp = project.objects.directoryProperty().fileValue(file("src/prodRelease/res"))
        googleServicesResourceRoot.value(myDirProp)
    }
}

This sets the googleServicesResourceRoot and successfully uploads the mapping file to Crashlytics.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bobtune