5

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

Jesus Dimrix
  • 4,378
  • 4
  • 28
  • 62
  • Are you including the buildtype as well? If you look at the list of gradle tasks, that jobs is generated for every flavor and build type – Pablo Baxter May 22 '20 at 20:17

2 Answers2

4

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.

VenomVendor
  • 15,064
  • 13
  • 65
  • 96
2

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.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216