Created
November 2, 2015 21:41
-
-
Save mandrachek/0a47a0d1e48aee860d6c to your computer and use it in GitHub Desktop.
dynamic ext.betaDistributionApkFilePath
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 { | |
splits { | |
abi { | |
enable true | |
reset() | |
include 'x86', 'armeabi', 'armeabi-v7a', 'mips', 'arm64-v8a' | |
universalApk true | |
} | |
} | |
} | |
android.applicationVariants.all { variant -> | |
ext.betaDistributionApkFilePath = "${buildDir}/outputs/apk/app-${variant.name}-universal-${variant.buildType.name}.apk" | |
} |
What error are you seeing or does the distribute just not occur?
-Mike
This worked for me... put it outside of the android {} block in the main app's build.gradle:
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")
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work :(
I'm trying to set the ext.betaDistributionApkFilePath dynamically so that I can account for variant name (flavor) and buildType (release/debug).
If I hardcode ext.betaDistributionApkFilePath on a per-flavor basis, I'm limited to just one buildType for that flavor. If I hardcode it for the build type, I'm limited to one build flavor for that build type.