// To Change the APK and Bundle Name
archivesBaseName = "${name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}"
(for this also tried to change the - variant.outputs.all
to variant.outputs.each
)
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = "${variant.buildType.name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}.apk"
}
}
When I use option One,
Issue - it generates all splits but it overrides the flavor config with the last flavor written in Gradle.
Also, try to put option One only once in defaultConfig
but as productFlavours written after that it returns the null
value in versionCode
and versionName
.
productFlavors {
aFlavor {
applicationId "com.a"
versionCode 5
versionName "1.0.5"
signingConfig signingConfigs.signingA
// To Change the APK and Bundle Name
archivesBaseName = "${name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}"
}
bFlavor {
applicationId "com.b"
versionCode 5
versionName "1.0.5"
signingConfig signingConfigs.signingB
// To Change the APK and Bundle Name
archivesBaseName = "${name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}"
}
cFlavor {
applicationId "com.c"
versionCode 3
versionName "1.0.3"
signingConfig signingConfigs.signingC
// To Change the APK and Bundle Name
archivesBaseName = "${name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}"
}
}
When I use option Two,
Issue - it generates the correct name but generates a single APK file.
splits {
abi {
enable true
reset()
include 'arm64-v8a', 'x86', 'x86_64'
universalApk false
}
}
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = "${variant.buildType.name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}.apk"
}
}
Issue for bundle - not able to rename the bundle using option Two.
As per This answer, you can go with Option - Two
with minor changes as mention below only works for APK
, not the Bundle / AAB files
splits {
abi {
enable true
reset()
include 'arm64-v8a', 'x86', 'x86_64'
universalApk false
}
}
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
// New one or Updated one
output.outputFileName = "${variant.getFlavorName()}-${variant.buildType.name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}-${output.getFilter(com.android.build.OutputFile.ABI)}.apk"
// Old one
// output.outputFileName = "${variant.buildType.name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}.apk"
}
}
Also, remove the line from each Flavor's block
// To Change the APK and Bundle Name
archivesBaseName = "${name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}"
By this, you get the output file name like this
aFlavor-release-v5_1.0.5-16Jan2020_21-26-arm64-v8a.apk
aFlavor-release-v5_1.0.5-16Jan2020_21-26-x86_64.apk
aFlavor-release-v5_1.0.5-16Jan2020_21-26-x86.apk
aFlavor-debug-v5_1.0.5-16Jan2020_21-26-arm64-v8a.apk
aFlavor-debug-v5_1.0.5-16Jan2020_21-26-x86_64.apk
aFlavor-debug-v5_1.0.5-16Jan2020_21-26-x86.apk
Similar name as above just change the prefix aFlavor
with bFlavor
like
bFlavor-release-v5_1.0.5-16Jan2020_21-26-arm64-v8a.apk
Similar name as above just change the prefix aFlavor
with cFlavor
and, versionCode
and versionName
as respected
cFlavor-release-v3_1.0.3-16Jan2020_21-26-arm64-v8a.apk
Because you are using universalApk false
, Gradle generates different output apk for each ABI. So you have to add ABI name to your output filename. The output.getFilter(com.android.build.OutputFile.ABI)
expression returns current ABI name.
Please look at the following example:
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = "${variant.buildType.name}-${output.getFilter(com.android.build.OutputFile.ABI)}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}.apk"
}
}
Remove app_name
from string.xml
file
apply plugin: 'com.android.application'
android {
signingConfigs {
release {
keyAlias 'your key alias'
keyPassword 'your password'
storeFile file('path of your keystore')
storePassword 'your password'
}
}
compileSdkVersion 28
flavorDimensions "default"
project.archivesBaseName = "ProjectName";
defaultConfig {
applicationId "Your package name"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
signingConfig signingConfigs.release
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.all { //output ->
outputFileName = "YourAppName-${variant.baseName}-${variant.versionName}.apk"
}
}
}
debug {
}
}
productFlavors {
dev {
versionCode 778899 // your versioncode
versionName "v.1.1.BUILD_NUM" // your version name
applicationIdPrefix ".dev" // your application package name like as com.a
resValue "string", "app_name", "Your App Name"
}
live {
versionCode 778899 // your versioncode
versionName "v.1.1.BUILD_NUM" // your version name
applicationIdPrefix ".dev" // your application package name like as com.a
resValue "string", "app_name", "Your App Name"
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
// Here your application gradle
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With