44

I have implemented Firebase crashlytics as suggested. I have put this in my app level release build variant:

firebaseCrashlytics
  {
    mappingFileUploadEnabled true
  }

but when I start to build signed apk I am always getting this error

Task :app:uploadCrashlyticsMappingFileRelease FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:uploadCrashlyticsMappingFileRelease'.

Expected file collection to contain exactly one file, however, it contains no files.

If I set mappingFileUploadEnabled to false then release apk builds successfully. I have searched a lot but couldn't find a work around. Anyone can help?

Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43
Reyjohn
  • 2,654
  • 9
  • 37
  • 63

11 Answers11

54

Error: "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."

I had something like this in build.gradle

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

changed it to this and voila! it works:

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
Dishant Mahajan
  • 616
  • 8
  • 5
28

I faced the same event today.The reason for this to happen is as follows.

If minify true is set, obfuscation will be applied at build time and mapping.txt will be created.

If minify false, it will not be obfuscated at build time and mapping.txt will not be created.

If you set mappingFileUploadEnabled true in the minify false state, the Firebase SDK will try to upload mapping.txt to Firebase even though mapping.txt is not created at build time. The result is an error.

So, if you set minify false, you have to set mappingFileUploadEnabled false, if you set minify true, you need to set mappingFileUploadEnabled true or false (when mappingFileUploadEnabled false, the crash log on Firebase was obfuscated. It may not make much sense as it will be displayed in state).

  • Hint

https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android#firebase-crashlytics-sdk_7

https://developer.android.com/studio/build/shrink-code#enable

fnami
  • 281
  • 3
  • 3
  • 1
    it looks like there is no need to mappingFileUploadEnabled to true when minify is true (https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android&%3Bhl=da&hl=ro#firebase-crashlytics-sdk_7) – David Aug 12 '21 at 17:28
  • For me it would fail when generating a signed APK, only, so I had to [disable the upload, entirely](https://stackoverflow.com/a/64115676/1540350)., otherwise it would say "Socket closed" and "Task :app:uploadCrashlyticsMappingFileRelease FAILED" and I don't know why. This is only a temporary solution, I'm not sure why the socket closes. This is on a Flutter app. The fun part is that it would work after restart until I decide to create a debug build again. – Martin Braun Aug 13 '21 at 00:50
  • `minifyEnabled false && shrinkResources false` Solved for me – Mohamed Slama Jun 14 '23 at 08:30
11

In my case I received the error because I wasn't connected to the internet. Fixed it by connecting to the internet and my build release worked perfectly for my Flutter App.

Tandoh Anthony Nwi-Ackah
  • 2,135
  • 2
  • 16
  • 30
  • 2
    Yes, same here. I was having slow internet connectivity at the time of the first attempt to build the APK. So after trying it for a second time, it worked fine. – Randika Vishman Jan 13 '22 at 08:26
10

I have resolved this issue by moving the following line from bottom of the page to top in build gradle.

Previous Settings:

apply plugin: 'com.google.gms.google-services'

New Settings:

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

And the issue is resolved.

MT Shahzad
  • 101
  • 1
  • 7
  • Good call. Not only from the bottom of the page to the top, but 'com.google.gms.google-services' should be on top of 'com.google.firebase.crashlytics' – tendai Jun 24 '21 at 19:17
8

Just change sequence of crashlytics, apply plugin as below :

// Put Google Service
apply plugin: 'com.google.gms.google-services'
// After that the Firebase Crashlytics plugin.
apply plugin: 'com.google.firebase.crashlytics'
Umeshkumar D.
  • 412
  • 4
  • 18
  • 2
    Congratulations, actually changing the order solved this specific problem. A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask'). > No value has been specified for property 'googleServicesResourceRoot'. – AllanRibas Aug 23 '21 at 15:35
3

Decreasing the version of the following

classpath "com.google.firebase:firebase-crashlytics-gradle:2.8.0"

to 2.6.0 solved my problem.

oiyio
  • 5,219
  • 4
  • 42
  • 54
2

In my case, it was not adding com.google.gms:google-services at all. The project is in Flutter and Flutter Firebase documents do not mention this.

Add these to android/build.gradle (check the latest versions on the internet):

classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'

Add these to at the very end of android/app/build.gradle:

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

For some reason, even if you have generated lib/firebase_options.dart with flutterfire, the plugin still wants google-services.json file you have got from Firebase. Paste that file into android/app/ directory. And it builds for release.

Eray Erdin
  • 2,633
  • 1
  • 32
  • 66
  • for me ``` apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' ``` should be on the top of your build.gradle. otherwise the error likely occurs – icgoogo Aug 02 '22 at 02:42
1

Add this at the bottom of your build.gradle file

apply plugin: 'com.google.gms.google-services'
superakabo
  • 27
  • 3
0

I have faced several times, and there is a different solution i have.

First of all: You need to open android module of that project.

Flutter -> Open Android module in Android Studio.

And then go to Gradle Scripts, find gradle.properties (Global properties) and remove this code

systemProp.http.proxyHost=
systemProp.https.proxyHost=
systemProp.https.proxyPort=80
systemProp.http.proxyPort=80
0

If you're working with GuardSquare's Dexguard solution. Order of your plugins should be,

plugins {
    // Google Services Plugin
    id 'com.google.gms.google-services'
    // Firebase Crashlytics Plugin.
    id 'com.google.firebase.crashlytics'
    // Dexguard Plugin
    id 'dexguard'
}

This way the uploading process of your mapping file is going to succeed.

0

In gradle-wrapper.properties adding the below block solved issue for me. Note: These properties should not be added to project level gradle.properties

systemProp.http.proxyHost=
systemProp.http.proxyPort=80
systemProp.https.proxyHost=
systemProp.https.proxyPort=80
Kavin S
  • 1
  • 1