50

In the old Crash reporting - there is easy way to upload. i didn't find it in the Crashlytics section

noogui
  • 15,376
  • 3
  • 18
  • 42
itzhar
  • 11,479
  • 6
  • 50
  • 57

4 Answers4

43

UPDATE: Firebase update their docs: see here

There is no need anymore to manually upload mapping file.

1 - To preserve the info Crashlytics needs for readable crash reports, add the following lines to your config file:

-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

2 - To let Crashlytics automatically upload the ProGuard or DexGuard mapping file, remove this line from the config file (app/proguard-rules.pro):

-printmapping mapping.txt

For faster builds with ProGuard, exclude Crashlytics. Add the following lines to your config file:

-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
Cris
  • 661
  • 10
  • 26
itzhar
  • 11,479
  • 6
  • 50
  • 57
  • I have proguard config file updated with mentioned rules. I see `:app:crashlyticsStoreDeobsRelease` `:app:crashlyticsUploadDeobsRelease` during the build. But all callstacks in firebase ui are obfuscated. – Michael Sotnikov Dec 18 '17 at 21:19
  • 3
    Actually you should NOT use -keep class com.crashlytics.** { *; } -dontwarn com.crashlytics.** per https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports – easycheese Jan 26 '18 at 13:34
  • 26
    `-printmapping mapping.txt` It should be removed from which config file? – q126y Mar 13 '18 at 06:28
  • 1
    @q126y `-printmapping ` can be found in `app/proguard-rules.pro` – Mark Pazon Jun 27 '18 at 05:45
  • 4
    this is not good. Google Play lets me upload the mapping. I will not use -keep linenumbers etc in production code. – SteelBytes Jul 25 '18 at 07:08
  • Not at all, ProGuard and DexGuard are both supported when the mapping file is uploaded at build. – Mike Bonnell Aug 06 '18 at 18:21
  • 3
    How do I upload a mapping file on both Firebase Crashlytics and the Play Console? If I remove `-printmapping mapping.txt` to automatically upload it on Firebase, the file is not generated and I can't manually upload it on the Play Console. – manfcas Oct 29 '18 at 11:37
  • My problem is i add all these line to proguard rules, most crashes show normally but some crashes show obfuscated. – Mahdi Sep 07 '19 at 06:45
  • Won't `-keepattributes SourceFile` somehow defeat the purpose of obfuscation? – Benjamin Bisinger Oct 10 '19 at 15:28
  • 1
    The mapping file is generated and stored here (Windows): C:\Users\\.crashlytics\com.crashlytics.tools\app-\deobs – Juan Franco Apr 15 '20 at 14:14
  • I did everything according to this: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android I use Android Studio's Build -> Generate Signed APK. I can see in the logs here (~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log) that the deobfuscation file was uploaded sucessfully. And, still my crashes in Firebase are obfuscated. Any ideas why? – hakobyanheghine Apr 28 '20 at 15:30
  • last paragraph for faster builds with ProGuard in firbase docs is different: -keep class com.google.firebase.crashlytics.** { *; } -dontwarn com.google.firebase.crashlytics.** link: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android – Saeed Arianmanesh May 13 '20 at 07:56
  • still getting the same error I follow this [link](https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android)please help me for same – Arbaz.in Mar 04 '21 at 06:40
23

Mike from Firebase here. Crashlytics in Firebase does not offer a way to upload mapping files outside of the build flow. I'm personally curious, did you use the manual upload frequently?

Mike Bonnell
  • 15,887
  • 3
  • 57
  • 72
  • 10
    Tnx Mike. Yes I use it a lot – itzhar Nov 14 '17 at 17:15
  • @itzhar would you be open to chatting about this more? Would love to understand the need for the manual upload outside of a build flow. – Mike Bonnell Nov 15 '17 at 14:17
  • 35
    @MikeBonnell, when it doesn't work as expected it's much more difficult to understand what's going wrong. Since there is no any idnication that mapping was uploaded - you don't know if everything is good - you need to get first crash/exception to check it. It's always better to have some control in own hands and have ability to fix it after if needed. – Michael Sotnikov Dec 18 '17 at 21:22
  • 4
    Thanks, I'll chat with the team about making it easier to look into the build tooling logs that show whether or not the uploads were successful or not. – Mike Bonnell Dec 18 '17 at 21:26
  • @MikeBonnell, our android app is written in Scala and we use sbt for building, so we are interesting in upload mapping.txt outside standard gradle build flow. – Vladimir Berezkin Dec 19 '17 at 12:04
  • 14
    @MikeBonnell +1 on getting better visibility of what Crashlytics is doing here, it's supposed to just work but so many of us are completely stumped when it doesn't. Question re the mapping.txt file, the docs say to remove `-printmapping mapping.txt` so that the file isn't generated and Crashlytics can do its thing. I have never had that line in my pro file but mapping.txt is still generated and I have never seen deobfuscated crash reports. Any insight on this quirk? Cheers – darnmason Mar 22 '18 at 04:44
  • 1
    There could be a variety of things happening @darnmason. If you want to look at logs, here's where they are, you just have to parse through them. On Linux / Windows: ~/.crashlytics/com.crashlytics.tools/crashlytics.log On Mac: ~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log – Mike Bonnell Mar 22 '18 at 14:13
  • Hmm I'm not seeing anything Crashlytics related in the Caches dir on Mac, a search for those dirs and file name also turned up blank, this was straight after running gradle assembleRelease – darnmason Mar 24 '18 at 01:44
  • Sounds like something else is going on then. I'd recommend email support(at)fabric(dot)io with a link to this thread, and your app's build.gradle. – Mike Bonnell Mar 25 '18 at 13:40
  • 2
    What if the prod build is being done by a machine with restricted internet access? Is there any ports or such that should be opened/configured? – jayeffkay Apr 13 '18 at 08:08
  • 2
    Whitelist *.fabric.io and *.crashlytics.com on ports 80 and 443. – Mike Bonnell Apr 13 '18 at 14:34
  • I just had Crashlytics report a crash and that was the first I knew the deobs file had failed to upload. On checking the crashlytics logs I now see `Crashlytics had a problem uploading the deobs file`. I re-ran the build and it uploaded OK this time, but it's a shame it fails in a non-obvious way and there's no way to manually upload. The existing crash isn't deobfuscated even though the re-run build has now uploaded it OK. I guess I just have to manually run retrace for this existing crash. In future I suppose I should tail the crashlytics log to make sure the upload works. – HexAndBugs Apr 13 '18 at 19:54
  • Thanks for the feedback, will share it with the team. – Mike Bonnell Apr 16 '18 at 20:48
  • I don't see an answer regarding the removal `-printmapping mapping.txt` @MikeBonnell We're building and deploying APK to Google Play from a jenkins/docker pipeline. We don't have any `printmapping` in our rules (custom or the default android), yet its created, and we archive it within Jenkins, but its NOT uploading to Crashlytics. Otherwise, the Triple-T plugin appears to be pushing it to Google Play console.. – alienjazzcat Apr 26 '18 at 22:07
  • See [this issue](https://issuetracker.google.com/issues/37090826). `mapping.txt` is generated automatically.. `printmapping` has gone through a stage, at least, where its not honored. This doesn't reconcile well with the advice to remove the rule so that the plugin will upload it automatically – alienjazzcat May 10 '18 at 18:35
  • @MikeBonnell I don't see `-printmapping mapping.txt` anywhere, and still I've noticed obfuscated stuff of my app on crashes, on Firebase Crashlytics. How come? Also `mapping.txt` is generated anyway, so I actually upload it to Play Console website. – android developer Jul 15 '18 at 19:59
  • There are a variety of reasons, if you're hitting this after going through the changes and answers here, best to contact Firebase support. – Mike Bonnell Jul 16 '18 at 13:58
  • 5
    @MikeBonnell It would be nice to have readable crash reports, just like we used to have on the old Firebase crash reporting system. You know, to make debugging actually possible, and stuff. – user3690202 Aug 04 '18 at 08:28
  • @MikeBonnell I landed up here because I think my stacktrace isn't correct in my app, so I was wondering if it was possible to upload it manually. I'm curious to hear how Crashlytics maps the auto-uploaded mapping.txt file with the installed version. If it's based on the version string, it might fail a lot of times for me, unfortunately.. – Anigif Oct 08 '18 at 11:02
  • 1
    Hey @Anigif the Gradle plugin generates a unique identifier so that our backend can identify your builds. This identifier is used to deobfuscate crashes and distribute the correct versions of your beta test builds. The identifier will be added to your res/values and looks like: RANDOM_UUID Reference: https://docs.fabric.io/android/crashlytics/build-tools.html#gradle-advanced-setup The version string doesn't matter. – Mike Bonnell Oct 08 '18 at 14:40
  • @MikeBonnell I don't see the need for Google to get notified every time I run a (release) build. – Carsten Hagemann Oct 16 '18 at 04:37
  • @CarstenHagemann Sorry, I'm not following what you're saying. When a build happens, we generate a unique id in order to map back to the correct mapping file uploaded with that build. – Mike Bonnell Oct 16 '18 at 13:16
  • 1
    @MikeBonnell This sentence "Crashlytics automatically uploads the mapping files for reach of your build variants." (source https://docs.fabric.io/android/crashlytics/dex-and-proguard.html) indicates to me that the mapping file is automatically uploaded every time I run a build. I don't think Google needs to know when and how often I run a build. Please correct me if my understanding is wrong. Thanks! – Carsten Hagemann Oct 17 '18 at 00:41
  • If you want our service to de-obfuscate your stack traces, then we need to have the mapping file for the build. If you don't want to upload a mapping file for each build, you can disable it - https://docs.fabric.io/android/crashlytics/build-tools.html#optimize-builds-when-you-re-not-proguarding-or-using-beta-by-crashlytics and https://docs.fabric.io/android/crashlytics/build-tools.html#disable-crashlytics-for-debug-builds – Mike Bonnell Oct 17 '18 at 14:19
  • I am unable to get it to work. I don't know how to find out what goes wrong. But the code remain obfuscated in the firebase console. I just want to upload my mapping.txt. Is there a way to manually to that? – Gillis Haasnoot Jan 10 '19 at 10:23
  • There is not a manual upload at the moment. You could take a look at the build.log output to try and diagnose the issue. Also, see this issue: https://stackoverflow.com/questions/53420776/crashlytics-not-uploading-mapping-file – Mike Bonnell Jan 10 '19 at 14:11
  • We have automated build after every commit. So, mapping files are uploaded to firebase after every commit. It would be nice to control, when to upload mappings and when not. – babay Nov 26 '19 at 17:53
  • 1
    Recently Firebase Crashlytics haven't uploaded my mapping file anymore. Not sure why but if I can upload mapping file myself it will be ok. If Google Play supports this feature then why FC doesnt't? – Wayne May 05 '20 at 03:16
  • @MikeBonnell As you see from Juan Franco's answer above, linking the upload of mapping.txt to build process makes the process so hidden that developer is not in the loop anymore to "retry the upload properly". If a connection error occurs during the automatic upload, it's logged but Android Studio doesn't make it explicit for the developer. Without such a screen to intervene embedded in Android Studio, Firebase console (web) is always a better way if it offers manual upload option (after we release to Play Store). – faraday Oct 09 '20 at 11:09
  • @MikeBonnell please add option to specify where the google-services.json file is. It is very frustrating to need to create folders that only contain the google-services.json file. Or allow me to manually upload the mappings. I do not want to depend on the crashlytics plugin for gradle – Lena Bru Apr 18 '21 at 20:09
7

If you have followed the indications to enable the automatic upload then build the app and you still see the stack traces obfuscated in Firebase you should check the log files:

On Linux / Windows: /.crashlytics/com.crashlytics.tools/crashlytics.log
On Mac: ~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log

Look for the latest entry with: Uploading deobfuscation file

And try to find the result of the operation like: Deobfuscation file(s) uploaded or Crashlytics had a problem uploading the deobs file and you will get some hints about the cause.

Juan Franco
  • 179
  • 1
  • 7
  • I cannot understand that. If automatically uploading every time I build, then mapping will be different, right? (e.g. after publishing app, I changed code again so my new uploaded mapping will work with previousely production code?) – FindOutIslamNow Apr 14 '20 at 06:31
  • Looks like every build has a unique id that is used to match the code with the obfuscation file. I found that id on the .meta files. – Juan Franco Apr 15 '20 at 14:15
2

Set the firebaseCrashlytics.enableMappingFileUpload Gradle extension property to true in your app-level build.gradle file.

// To enable Crashlytics mapping file upload for specific product flavors:
  flavorDimensions "environment"
  productFlavors {
    staging {
      dimension "environment"
      ...
      firebaseCrashlytics {
        mappingFileUploadEnabled false
      }
    }
    prod {
      dimension "environment"
      ...
      firebaseCrashlytics {
        mappingFileUploadEnabled true
      }
    }
  }

for more details visit Click here

Mansukh Ahir
  • 3,546
  • 4
  • 36
  • 58