Crashlytics NDK symbols and Gradle tasks
Asked Answered
G

2

2

I have a question that mostly relates to gradle.

I'm using Crashlytics to report NDK crashes in my Android app. I have a task in build.gradle that calls ndk-build and compiles the cpp files into an .so file. At the end of this task I want to call a task that uploads generated symbols mapping to Crashlytics.

After installing the Fabric plugin in Android Studio, I saw there are some new tasks that were added to the Gradle tab. One of them is crashlyticsUploadSymbols[buildType][flavour] where buildType and flavour indicate which buildtype and flavour is currently selected.

This task does seem to upload a symbols file.

My question is, Is it possible to call this task from within build.gradle? Currently I use a manual call in Android Studio's terminal tab in the form of:

./gradlew crashlyticsUploadSymbols[buildType][flavour]

Is it possible to call this task somehow from within build.gradle?

To call this task I use finalizedBy at the end of the buildNdk task, so once buildNdk has finished, the upload task will execute.

Also very important, how can I get the current buildType and flavour so I am able to add it to the crashlyticsUploadSymbols call?

Thank you!

Glean answered 25/5, 2016 at 11:33 Comment(0)
D
4

Mike from Crashlytics and Fabric here.

This was also answered on the Twitter Community forum's, but sharing the same answer here.

Option 1:

If you only want or need to upload symbols for your release builds, then you can set crashlticsUploadSymbolsRelease as the finalizedBy task for your ndk-build task.

Option 2: If you have multiple variant-based tasks, you can do something like:

android.applicationVariants.all { variant ->
    def variantName = variant.name.capitalize()
    def task = project.task ("ndkBuild${variantName}")
    task.finalizedBy project.("crashlyticsUploadSymbols${variantName}")
}
Doddered answered 26/5, 2016 at 15:8 Comment(2)
This doesn't work for me, i get Error:(101, 0) Cannot add task ':App:externalNativeBuildProdDebug' as a task with that name already exists. <a href="openFile:/path/to/app/build.gradle">Open File</a> so still have to upload manually :(Crossruff
Sounds like you may have a duplicate task, but I'd recommend posting a new question with more details.Doddered
F
1

The following did the job for me:

android {
...
    afterEvaluate {
        assembleDebug.finalizedBy(crashlyticsUploadSymbolsDebug)
        assembleRelease.finalizedBy(crashlyticsUploadSymbolsRelease)
    }
}
Freon answered 6/12, 2017 at 15:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.