Nick
Nick

Reputation: 3461

How to upload Crashlytics symbols automatically

My Android project consists of library and app. The library has C++ code, so it uses NDK support. I am working on integrating Crashlytics into the project, and I want to automatically upload symbols after release has been built.

The library's build.gradle looks as follows:

// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
    def ndkDir = android.ndkDirectory
    commandLine "$ndkDir\\ndk-build.cmd",
            '-C', file('../../Android_Jni').absolutePath,
            '-j', Runtime.runtime.availableProcessors()
}

task upload {
    doLast {
        println('Uploading...')
        crashlyticsUploadSymbolsRelease
    }
}

ndkBuild.finalizedBy(upload)

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn ndkBuild
}

Uploading seems to work, but it happens both when I build debug and release flavours (which I select in Build Variants in Android Studio). Is it possible to modify script so that it would only upload symbols after release build has finished?

Upvotes: 2

Views: 1019

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57203

something like this:

if (gradle.startParameter.taskNames && gradle.startParameter.taskNames[0].endsWith('Release') ) {
    ndkBuild.finalizedBy(upload)
}

Upvotes: 1

Related Questions