diff --git a/app/build.gradle b/app/build.gradle index 3a2fcd4..cf77365 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,6 +2,11 @@ plugins { id 'com.android.application' } +def static releaseTime() { + return new Date().format("yyyyMMdd_HHmmss", TimeZone.default) +} + + android { namespace 'cc.niushuai.dididone' compileSdk 34 @@ -10,9 +15,11 @@ android { applicationId "cc.niushuai.dididone" minSdk 24 targetSdk 32 - versionCode 1 + versionCode 12 versionName "1.2" + resValue "string", "weathericons_version", "${versionName}" + javaCompileOptions { annotationProcessorOptions { arguments += [ @@ -38,6 +45,19 @@ android { buildFeatures { viewBinding true } + + android.applicationVariants.all { + variant -> + variant.outputs.all { + //这里修改apk文件名 + outputFileName = "${getAppName()}_v${variant.versionName.replaceAll('\\s+', '_')}_${releaseTime()}_${variant.buildType.name}.apk" + } + } +} + +def getAppName() { + def stringsFile = android.sourceSets.main.res.sourceFiles.find { it.name.equals 'strings.xml' } + return new XmlParser().parse(stringsFile).string.find { it.@name.equals 'app_name' }.text() } dependencies {