android
[j android] apk 파일명 변경하기
simpleyj
2020. 5. 18. 13:51
728x90
반응형
app수준 build.gradle에 추가한다.
android { //add inside the android {}
......
applicationVariants.all { variant ->
variant.outputs.all {
def flavor = variant.name
def versionName = variant.versionName
outputFileName = "appname_${flavor}_${versionName}.apk"
}
}
}
파일명 결과
appname_release_1.0.1.apk
applicationVariants.all { variant ->
variant.outputs.all { output->
def apk = output.outputFile
def packageName = defaultConfig.applicationId
def versionName = defaultConfig.versionName
def dateStr = new Date().format("yyyyMMdd")
def newName
if (apk != null && apk.name.startsWith('app-release')) {
newName = apk.name.replace("app-release", dateStr + "_" + packageName + "_" + versionName);
}else{
newName = apk.name.replace("app-debug", dateStr + "_" + packageName + "_" + versionName);
}
outputFileName = newName
}
}
728x90
반응형