是否可以指定../build/apk/以外的Android * .apk文件构建位置?是否可以为每种口味指定不同的位置?
我正在使用Android Studio。
最佳答案
多数民众赞成在我的工作:
android.applicationVariants.all { variant ->
def outputName = // filename
variant.outputFile = file(path_to_filename)
}
但是“清理”任务不会删除该apk,因此您应该按以下方式扩展清理任务:
task cleanExtra(type: Delete) {
delete outputPathName
}
clean.dependsOn(cleanExtra)
完整样本:
apply plugin: 'android'
def outputPathName = "D:\\some.apk"
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
applicationVariants.all { variant ->
variant.outputFile = file(outputPathName)
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
task cleanExtra(type: Delete) {
delete outputPathName
}
clean.dependsOn(cleanExtra)
关于android - Gradle-如何为每种口味指定不同的Android * .apk构建位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23279732/