我正在尝试根据调试或 Release模式设置目标文件夹。但我并没有真正成功。对于调试和发布,它总是转到调试文件夹。如果我删除调试配置,那么它会转到发布文件夹,但它们都是(发布和调试)。
我想我必须修改运行配置,但我不确定该怎么做。
有什么帮助吗?
渐变文件:
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 18
versionName "0.70"
}
signingConfigs {
release {
storeFile file("xxxx")
storePassword "xxxx"
keyAlias "xxx"
keyPassword "xxxx"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
applicationVariants.all { variant ->
def file = variant.outputFile
variant.outputFile = new File("C:\\PATH_TO_FOLDER\\release", "name" + defaultConfig.versionName + ".apk")
}
}
debug {
applicationVariants.all { variant ->
def file = variant.outputFile
variant.outputFile = new File("C:\\PATH_TO_FOLDER\\debug", "name_DEBUG_" + defaultConfig.versionName + ".apk")
}
}
}
}
最佳答案
好吧……我想通了。
不确定这是否是最佳解决方案,但我检查了构建类型的名称,然后根据它设置了输出文件夹。
buildTypes {
release {
signingConfig signingConfigs.release
}
applicationVariants.all { variant ->
def file = variant.outputFile
println "Build info: $variant.buildType"
if (variant.buildType.name=="release") {
println "Release mode"
variant.outputFile = new File("C:\\PATH_TO_FOLDER\\verify", "app" + defaultConfig.versionName + ".apk")
} else {
variant.outputFile = new File("C:\\PATH_TO_FOLDER\\debug", "app_DEBUG_" + defaultConfig.versionName + ".apk")
}
}
}
关于android - 调试时 Gradle Android studio 输出文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24363850/