AndroidStudioで開発しているが、デフォルトのファイル名でapkが作成されるが、バージョン管理のために毎回リネームしていたが。
めんどくなってきたので、Gradleでバージョン名がつくように設定してみた。
apply plugin: 'com.android.application'
android {
defaultConfig {
・・・
minSdkVersion 11
targetSdkVersion 19
versionCode 3
versionName "1.1"
・・・・
}
・・・
applicationVariants.all { variant ->
if (variant.buildType.name.equals("release")) {
def file = variant.outputFile
def newName = "<filename>_ver${defaultConfig.versionName}.apk"
variant.outputFile = new File(file.parent, newName)
}
}
}
- 例:
が「MyApp」の場合、「MyApp_ver1.1.apk」が作成されます。