android 自定义打包名称

发布于 2025-08-24 22:38:17

app目录下build.gradle 中android节点加上以下代码

 android.applicationVariants.all {

        outputs.all {

            if (this is com.android.build.gradle.internal.api.ApkVariantOutputImpl) {

                val config = project.android.defaultConfig

                val versionName = config.versionName

                val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HHmm")

                val createTime = LocalDateTime.now().format(formatter)

                this.outputFileName = "${rootProject.name}\_${this.name}_${versionName}\_$createTime.apk"

            }

        }

    }

0 条评论

发布
问题