Android gradle Upload NDK symbols on every build

Viewed 1212

I want to upload NDK symbols on every build i do,

Under my Android inside gradle i use to have:

applicationVariants.all { variant ->
    def variantName = variant.name.capitalize()
    println("symbols will be added on varinat ${variantName}")
    def task = project.task("ndkBuild${variantName}")
    task.finalizedBy project.("uploadCrashlyticsSymbolFile${variantName}")
}
  1. this does not compile anymore since i moved to FireBase :

    Could not get unknown property 'uploadCrashlyticsSymbolFile

  2. I don't see this task running.

  3. I basiclly need this task to run on every build:

    ./gradlew app:assembleBUILD_VARIANT\ app:uploadCrashlyticsSymbolFileBUILD_VARIANT

2 Answers

Add this at the bottom of app's build.gradle outside android { ... } block.

afterEvaluate {
    android.applicationVariants.all { variant ->
        def variantName = variant.name.capitalize()
        println("symbols will be added on variant ${variantName}")

        def task = tasks.findByName("assemble${variantName}")
        def uploader = "uploadCrashlyticsSymbolFile${variantName}"

        // This triggers after task completion
        task?.finalizedBy(uploader)

        // This ensures ordering
        task?.mustRunAfter(uploader)
    }
}

You can try without afterEvaluate block. It should still work.

Likely you'd need to use Firebase App Distribution, which permits automatic upload of release build artifacts - and if you have the artifact with the matching debug symbols, they could actually be used - without the matching assembly, the symbols are somewhat irrelevant.

Number 1 is obviously a wrongful assumption, because the documentation clearly states:

./gradlew app:assembleBUILD_VARIANT app:uploadCrashlyticsSymbolFileBUILD_VARIANT

And this is already answered here.


In order to always upload, one can create a task dependency:

assembleRelease.finalizedBy uploadCrashlyticsSymbolFileRelease

This may require setting unstrippedNativeLibsDir and strippedNativeLibsDir.

Related