Skip to content

Instantly share code, notes, and snippets.

@mandrachek
Created November 2, 2015 21:41
Show Gist options
  • Save mandrachek/0a47a0d1e48aee860d6c to your computer and use it in GitHub Desktop.
Save mandrachek/0a47a0d1e48aee860d6c to your computer and use it in GitHub Desktop.
dynamic ext.betaDistributionApkFilePath
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"
}
@dominicthomas
Copy link

dominicthomas commented Nov 25, 2016

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