我在我的项目中使用com.android.tools.build:gradle-experimental:0.6.0-alpha3插件。我的构建gradle看起来像:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 19
buildToolsVersion = "19.1.0"
defaultConfig.with {
applicationId = "com.my.company"
minSdkVersion.apiLevel = 9
targetSdkVersion.apiLevel = 19
versionCode = 2
versionName = "0.0.4"
}
}
android.ndk {
moduleName = "native"
stl = "gnustl_static"
cppFlags.add("-I" + file("../../src").absolutePath)
cppFlags.add("-std=gnu++11")
cppFlags.add("-fexceptions")
cppFlags.add("-frtti")
ldLibs.add("log")
ldLibs.add("GLESv2")
ldLibs.add("android");
}
android.sources {
main {
assets {
source {
srcDir "../../assets"
}
}
res {
source {
srcDirs = ['../../res']
}
}
jni {
source {
srcDir "../../src"
}
}
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file("proguard-rules.pro"))
}
}
android.productFlavors {
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("google") {
ndk.abiFilters.add("armeabi")
ndk.abiFilters.add("armeabi-v7a")
}
create("amazon") {
ndk.abiFilters.add("armeabi")
ndk.abiFilters.add("armeabi-v7a")
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
我需要为Google Play商店和亚马逊商店应用包含不同的.jar文件。我添加了2种口味的谷歌和亚马逊相应的名称,并添加了两行到我的依赖块:
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
googleCompile fileTree(dir: 'libs/google', include: ['*.jar'])
amazonCompile fileTree(dir: 'libs/amazon', include: ['*.jar'])
}
问题是,在这个改变之后我得到了procen项目,因为gradle无法解析并且给出了错误: 未找到Gradle DSL方法:' googleCompile()'
任何人都可以帮助我或寻找正确的问题研究方法。 谢谢。