I've the following app build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "io.gresse.hugo.anecdote"
minSdkVersion 16
targetSdkVersion 23
versionCode 12
versionName "1.0.0"
}
buildTypes {
release {
archivesBaseName = "anecdote-" + defaultConfig.versionName
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
archivesBaseName = "anecdote-DEBUGDEBUGDEBUG-"
}
}
}
When I execute ./gradlew assembleRelease assembleDebug
The output .apk are:
- anecdote-DEBUGDEBUGDEBUG-debug-unaligned.apk
- anecdote-DEBUGDEBUGDEBUG-debug.apk
- anecdote-DEBUGDEBUGDEBUG-release-unaligned.apk
- anecdote-DEBUGDEBUGDEBUG-release.apk
What I wanted:
- anecdote-DEBUGDEBUGDEBUG-debug-unaligned.apk
- anecdote-DEBUGDEBUGDEBUG-debug.apk
- anecdote-1.0.0-release-unaligned.apk
- anecdote-1.0.0-release.apk
Is there any way to apply the archiveBaseName to a specific build types or is it a bug?
Thanks,
As you may notice, this question is a mess around SO.
Related answer here and here.
Here is what worked for me. I wanted to keep the simple archiveBaseName
but it seems deprecated and that it apply to all buildTypes.
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "io.gresse.hugo.anecdote"
minSdkVersion 16
targetSdkVersion 23
versionCode 12
versionName "1.0.0"
}
project.ext.set("archivesBaseName", "Anecdote");
applicationVariants.all { variant ->
variant.outputs.each { output ->
if(variant.buildType.name == "release"){
output.outputFile = new File(
output.outputFile.parent,
output.outputFile.name.replace(".apk", "-"+variant.versionName + ".apk"))
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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