Crashlytics for Android: Disable automatic upload of mapping file via Gradle build
Asked Answered
H

6

6

I'd like to use crashlytics in our app, but I'm not allowed to upload it's proguard mapping file anywhere to the outside world (company policy). Is it possible to use Crashlytics but with obfuscated stacktraces?

In io.fabric plugin's docs I've found this option:

ext.enableCrashlytics = false

But it disables whole reporting, so that's not what I want.

Hawkie answered 10/6, 2015 at 11:6 Comment(0)
M
13

I have added this at the end of app gradle file:

tasks.whenTaskAdded {task ->
    if(task.name.toLowerCase().contains("crashlytics")) {
        task.enabled = false
    }
}

Build log:

> Task :app:crashlyticsStoreDeobsDebug SKIPPED
> Task :app:crashlyticsUploadDeobsDebug SKIPPED

Please note that this disables all crashlytics related tasks. Uploading proguard mapping file by default is some kind of misunderstanding. It is like uploading private key and its password. This file should only be stored in your vault. So I guess it is better to completely disable all their task by default :)

I am just wondering why this is not a big issue for developers.

Missi answered 25/1, 2019 at 21:52 Comment(0)
V
4

Add to app build Gradle file

firebaseCrashlytics {
        mappingFileUploadEnabled false
    }

https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android

Valentinevalentino answered 15/9, 2021 at 13:30 Comment(1)
Note this needs to be added to the build type definition: android { buildTypes { release { firebaseCrashlytics { mappingFileUploadEnabled false } } } }Madriene
A
2

They have everything planned ! ;-) According to this link : "Crashlytics automatically de-obfuscates stack traces for your reports", so you shouldn't have to worry about it.

Simply obfuscate your app with ProGuard, don't forget to update ProGuard rules to avoid unexpected crashes with release app, and it should be ok !

(help page is about Eclipse, but I used Crashlytics with Android Studio just some days ago, and it works fine too)

EDIT 1 : and according to the very end of this second link, Crashlytics automatically upload mapping file during build. It seems you aren't able to disable this.

EDIT 2 : maybe if you use Ant, you would be able to customize (at least a bit) build rules, thanks to crashlytics_build.xml and crashlytics_build_base.xml files. But I'm not used to Ant, and even there, when I read file, it seems the "mapping files auto upload" can't be disabled. :-/

Argentinaargentine answered 10/6, 2015 at 11:32 Comment(5)
I know it's done automagically, but mapping file is still required :) AFAIK, during the build, io.fabric plugin just uploads it to crashlytics. My problem is that this file is considered "vulnerable data" and so I have to prevent the upload.Hawkie
Sorry for the misunderstanding ;-) I edited my answer, hope it will help.Argentinaargentine
Build hacking is always the last resort, I just hoped there is some more elegant solution :) Thanks anyway!Hawkie
We managed to do this this way: task renameMappingFile << { file("build/outputs/mapping").renameTo(file("build/outputs/mapping-internal")) } afterEvaluate { for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsStoreDeobs') }) { task.dependsOn renameMappingFile } }Hawkie
Be careful though, Crashyltics documentation says to use those proguard settings -keepattributes SourceFile,LineNumberTable,*Annotation* But you should be aware "SourceFile" setting will actually leak your source file name in each obfuscated class in your APK binary! Make the whole obfuscation suddendly less robust..Husbandman
R
1

try disable task 'crashlyticsUploadDeobs':

afterEvaluate {
    for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsUploadDeobs') }) {
    task.enabled = false
}}
Raulrausch answered 12/6, 2018 at 11:56 Comment(0)
B
0

if you does not have internet connect at that time what will happened mapping will upload to crashlytics or not.

Branham answered 20/1, 2017 at 9:24 Comment(0)
F
0

Check following link to see the latest approach: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android

Fitch answered 5/3, 2024 at 14:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.