Rename output APK
This commit is contained in:
@@ -31,6 +31,29 @@ android {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
applicationVariants.all{
|
||||
variant ->
|
||||
variant.outputs.each{
|
||||
output->
|
||||
// on below line we are specifying our app name.
|
||||
project.ext { appName = 'kirbyTestApp' }
|
||||
// on below line we are adding the formatted date to our apk file name.
|
||||
def formattedDate = new Date().format('yyyyMMdd')
|
||||
// on below line we are creating a new name for our apk.
|
||||
def newName = output.outputFile.name
|
||||
// on below line we are replacing our previous name with our app name.
|
||||
newName = newName.replace("app-", "$project.ext.appName-")
|
||||
// 當build type為 debug時觸發
|
||||
// on below line we are replacing -debug with our formatted date.
|
||||
newName = newName.replace("-debug", "-debug-" + formattedDate)
|
||||
// 當build type為 release時觸發
|
||||
// on below line we are replacing -release with our formatted date.
|
||||
newName = newName.replace("-release", "-release-" + formattedDate)
|
||||
// at last we are setting our apk name to it.
|
||||
output.outputFileName = newName
|
||||
}
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
|
||||
Reference in New Issue
Block a user