在项目的model的Gradle下:
android {
defaultConfig {
applicationId "XXX.XXX"
minSdkVersion rootProject.ext.min_sdk_version
targetSdkVersion rootProject.ext.target_sdk_version
versionCode 12
versionName "1.0.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
....
applicationVariants.all { variant ->
variant.outputs.all {
// Rename APK
def versionName = defaultConfig.versionName
def date = new java.text.SimpleDateFormat("yyyyMMdd_HHmm").format(new Date())
outputFileName = "app_${variant.buildType.name}_${versionName}_${date}.apk"
}
}
....
}
这样的话,生成的apk就不会覆盖原来的apk