Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created November 25, 2016 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominicthomas/d8d41cd378c7a0a3fc21394c3ef84b15 to your computer and use it in GitHub Desktop.
Save dominicthomas/d8d41cd378c7a0a3fc21394c3ef84b15 to your computer and use it in GitHub Desktop.
Code to upload a build to crashlytics even when setting a custom apk name.
android {
...
debug {
debuggable true
...
ext.betaDistributionGroupAliases = "Android-Test"
}
...
project.android.applicationVariants.all { variant ->
variant.preBuild.doLast {
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent, variantApkName(variant, output))
}
}
}
}
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
tasks.findAll {
it.name.startsWith("crashlyticsUploadDistribution${variant.name.capitalize()}")
}.each {
it.doFirst {
ext.betaDistributionApkFilePath = "${buildDir}/outputs/apk/" + variantApkName(variant, output)
}
}
}
}
// Here you choose the custom file naming convention for your apk, also use when actually setting the filename.
def variantApkName(variant, output) {
return output.outputFile.name.replace(".apk", "-v${variant.versionName}-${variant.versionCode}.apk")
}
// Call ./gradlew crashlyticsUploadDistribution<variant name> to upload to fabric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment