I want to change the generated name of the .apk file in my build gradle. based on which buildtype i choose. It automatically appends "-release" or "-debug". How can I change this?
Build gradle file
android {
signingConfigs {
testapp {
storeFile file("itsASecret")
storePassword "itsASecret"
keyAlias "itsASecret"
keyPassword "itsASecret"
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
def versionPropertiesFile = file('version.properties')
if (versionPropertiesFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropertiesFile))
def code = versionProps['VERSION_CODE'].toInteger() + 1
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropertiesFile.newWriter(), null)
defaultConfig
{
applicationId "com.testapp.app"
minSdkVersion 19
targetSdkVersion 22
versionCode code
versionName "1.02.00"
multiDexEnabled true
setProperty("archivesBaseName", "TestApp_" + "$versionName" + "_" + "$versionCode")
}
} else {
throw new GradleException("Could not read version.properties!")
}
buildTypes
{
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.testapp
}
debug {
debuggable true
signingConfig signingConfigs.testapp
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
signingConfig signingConfigs.railway
}
}
I tried something like
applicationIdSuffix "_DEBUGTEST"
or
versionNameSuffix "_DEBUGTEST"
Filename:
TestApp_1.02.00_458-release.apk
TestApp_1.02.00_458-debug.apk
But this is not working :-(
EDIT:
I do have a common library with another build gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.squareup.retrofit:retrofit:1.7.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'de.greenrobot:greendao:1.3.7'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-codec:commons-codec:1.10'
compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
compile 'log4j:log4j:1.2.16'
compile 'org.slf4j:slf4j-api:1.6.4'
compile 'org.slf4j:slf4j-log4j12:1.6.4'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'commons-net:commons-net:3.3'
compile 'net.lingala.zip4j:zip4j:1.3.2'
compile 'com.jjoe64:graphview:4.0.1'
}