【发布时间】:2014-04-24 21:01:49
【问题描述】:
除了 ../build/apk/ 之外,有没有办法指定 Android *.apk 文件的构建位置?是否可以为每种口味指定不同的位置?
我正在使用 Android Studio。
【问题讨论】:
除了 ../build/apk/ 之外,有没有办法指定 Android *.apk 文件的构建位置?是否可以为每种口味指定不同的位置?
我正在使用 Android Studio。
【问题讨论】:
这对我有用:
android.applicationVariants.all { variant ->
def outputName = // filename
variant.outputFile = file(path_to_filename)
}
但是“clean”任务不会删除那个apk,所以你应该像下面这样扩展clean任务:
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)
【讨论】: