我正在使用Android Studio 0.4.5并且无法同步gradle.
当我尝试这样做时,我收到此错误:
Gradle 'MyApp' project refresh Failed: Build script error,unsupported Gradle DSL method found: 'android()'!
我的解决方案包含4个模块这是我的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()
}
}
和其他人(为简单起见,我删除了依赖项)
第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单元
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'
}
}
很抱歉让这么久,但我在这里绝望了:(
最佳答案
主要原因是:
android {
packagingOptions {
exclude 'Meta-INF/LICENSE.txt'
}
}
在根build.gradle中.