在moudle中的build.gradle
android { ... //修改输出的APK路径 applicationVariants.all { variant -> // 打包完成后复制到的目录 def outputFileDir = "${project.projectDir.absolutePath}/apk/${variant.buildType.name}/${variant.versionName}" //确定输出文件名 def today = new Date() def path = ((project.name != "app") ? project.name : rootProject.name.replace(" ", "")) + "_" + variant.flavorName + "_" + variant.buildType.name + "_" + variant.versionName + "_" + today.format('yyyyMMddhhmm') + ".apk" variant.outputs.forEach { it.outputFileName = path } // 打包完成后做的一些事,复制apk到指定文件夹 variant.assemble.doLast { File out = new File(outputFileDir) copy { variant.outputs.forEach { file -> copy { from file.outputFile into out } } } } } }