Created
November 25, 2016 10:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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