78

After updating the classpath I can no longer build a release version of the app.

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask').
  - Type '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.



    A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask').
  - Type 'UploadMappingFileTask' property 'googleServicesResourceRoot' doesn't have a configured value.

I tried to read the changelog but no guidelines or documentation about it.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Bitwise DEVS
  • 2,858
  • 4
  • 24
  • 67

6 Answers6

140

To fix it, the Google Services plugin should be applied before any Firebase plugin in /app/build.gradle.

This produces the error:

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'

While this does not:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf

Note that com.google.gms.google-services is ABOVE com.google.firebase.crashlytics.

When you update to com.google.firebase:firebase-crashlytics-gradle:2.7.0 and sync the changes, you are given a message stating that is the fix as follows:

Configure project :app
Crashlytics could not find Google Services plugin task: processReleaseGoogleServices. Make sure com.google.gms.google-services is applied BEFORE com.google.firebase.crashlytics. If you are not using the Google Services plugin, you must explicitly declare `googleServicesResourceRoot` inputs for Crashlytics upload tasks.
Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
RRiVEN
  • 2,519
  • 2
  • 14
  • 13
  • 9
    I remember to put that line at the bottom (see [here](https://stackoverflow.com/a/38202698/3559908))... Now it's changed again... – Vall0n Aug 25 '21 at 12:29
  • 1
    @Vall0n They changed it in the documentation to be in the very top: https://firebase.google.com/docs/android/setup#add_the_sdk – MBH Nov 30 '21 at 12:29
  • Fixed the issue, but gradle starts showing a warning: "Warning: Please apply google-services plugin at the bottom of the build file." :) – Guy Dec 12 '21 at 13:06
22

Make sure

'com.google.gms.google-services'

is applied before:

'com.google.firebase.crashlytics'

Fixed the error for me.

sebastian
  • 2,610
  • 2
  • 17
  • 28
5

I also didn't found anything, for now changing to firebase-crashlytics-gradle to 2.6.1 seems ok.

Damiancioo
  • 462
  • 3
  • 13
2

This happened for me when I was testing minifyEnabled true in my debug builds.

Adding the following to my debug buildTypes resolved the issue for me.

      firebaseCrashlytics
          {
            mappingFileUploadEnabled false
          }
Bill Mote
  • 12,644
  • 7
  • 58
  • 82
1

My project didn't use 'com.google.gms.google-services'. You need to add 'com.google.gms.google-services' to the app level Gradle file in the plugins and, its corresponding classpath dependency classpath 'com.google.gms:google-services:latest-version' in the project level Gradle file.

Also make sure com.google.gms.google-services comes before com.google.firebase.crashlytics as stated by other answers.

Rawlin Crasto
  • 195
  • 2
  • 8
0

I already had the apply plugin lines in the correct order, yet I was still getting the build error and sync warning about the plugin task not being found. I considered the possibility of upgrading google-services, but version 4.1.0 was as high as I could make it. Any higher, and I would get errors about library dependencies not being found.

It turned out not only did I need to upgrade google-services to 4.3.14, defining the mavenCentral() repository in the project-level build.gradle wasn't enough; it also needed to be defined in the app-level build.gradle.

buildscript {
    repositories {
        google()
        mavenCentral() // Add this line
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

Nowhere in the Get Started documentation did it mention needing to do this, so hopefully, this will help anyone who gets stuck in the same situation I was in.