构建脚本错误,发现不受支持的 Gradle DSL 方法:'android()'! [英] Build script error, unsupported Gradle DSL method found: 'android()'!
本文介绍了构建脚本错误,发现不受支持的 Gradle DSL 方法:'android()'!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是 Android Studio 0.4.5,但在同步 gradle 时遇到问题.
I'm using Android Studio 0.4.5 and having troubles syncing gradle.
当我尝试这样做时,我收到此错误:
When I try to do that I get this error:
Gradle 'MyApp' project refresh failed: Build script error, unsupported Gradle DSL method found: 'android()'!
我的解决方案包含 4 个模块.这是我的根 build.graddle
:
My solution contains 4 modules. Here is my root build.graddle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
allprojects {
repositories {
mavenCentral()
}
}
以及其他(为了简单起见,我删除了依赖项)
And the others (I removed dependencies for simplicity)
模块 1
apply plugin: 'android'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
模块 2
apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
模块 3应用插件:'android-library'
Module 3 apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
模块 4
apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
抱歉让我写这么长,但我在这里很绝望:(
Sorry for making this so long, but I'm getting desperate here :(
推荐答案
主要原因是:
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
在根 build.gradle 中.
in the root build.gradle.
这篇关于构建脚本错误,发现不受支持的 Gradle DSL 方法:'android()'!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文