【发布时间】:2016-10-05 23:10:59
【问题描述】:
我尝试在 Android Studio 中导入一个项目。导入时,Gradle 出现错误:
Gradle sync failed: Unable to find method
'org.gradle.api.artifacts.Configuration.setExtendsFrom(Ljava/lang/Iterable;)Lorg/gradle/api/artifacts/Configuration;'.
我试过了:
重新下载依赖和同步项目:失败(同样的错误)。
停止 Gradle 构建过程:失败(同样的错误)。
删除主目录中的 .graddle:失败(同样的错误)。
使缓存无效并重新启动失败(同样的错误)。
卸载并重新安装 Android Studio 和 SDK:失败(同样的错误)。
/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
/app/build.gradle
apply plugin: 'com.android.application'
//apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'xxx.xxx.xxx'
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildPB {
debuggable false
jniDebuggable false
renderscriptDebuggable false
zipAlignEnabled true
}
}
productFlavors {
}
// lintOptions {
// abortOnError false
// }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile ('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'net.sf.opencsv:opencsv:2.3'
compile 'de.greenrobot:greendao:1.3.7'
// You must install or update the Support Repository through the SDK manager to use this dependency.
// compile 'com.android.support:support-v4:19.+'
}
【问题讨论】:
-
要排除的几件事,尝试清除构建文件夹并在任务管理器中停止 java,这通常可以解决我遇到的大多数 gradle 问题
-
更专注地构建日志。就我而言,我已经过时了 AppCenter gradle 插件
标签: java android android-studio gradle