我目前正在使用 Gradle Experimental 0.2.1,但是我不能使用更新的版本。
我不知道它是否相关,但我需要使用新的 Vectore 支持。
我尝试添加vectorDrawables.useSupportLibrary = true
阻止defaultConfig.with
,但 Gradle Sync 会失败,说它无法识别此功能。
我得到的错误是:
错误:没有这样的属性:类的vectorDrawables:com.android.build.gradle.managed.ProductFlavor
这是我的 Gradle 构建文件:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = '22.0.1'
defaultConfig.with {
applicationId = "my.application.com
minSdkVersion.apiLevel = 18
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
vectorDrawables.useSupportLibrary = true // this will fail
}
}
android.packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/DEPENDENCIES'
}
// NDK
android.ndk {
moduleName = "MyAwesomeJNILib"
cppFlags += "-std=c++11"
stl = 'gnustl_shared'
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
debug {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
debuggable = true
}
}
android.productFlavors {
create("demo") {
applicationId = "my.application.com.demo"
}
create("dev") {
applicationId = "my.application.com.dev"
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
在依赖项块中,我确保使用
编译'com.android.support:appcompat-v7:23.4.0'