Gradle项目刷新失败(AS 0.8.2,Mac)

时间:2014-07-16 17:01:41

标签: android gradle android-studio android-gradle

有了一个空白的新项目,我明白了:

Gradle 'HelloWorld' project refresh failed
    Error:Cause: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

尝试构建时,我收到以下Gradle Build错误:

Error:A problem occurred configuring root project 'HelloWorld'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:0.12.+.
     Required by:
         :HelloWorld:unspecified
      > org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

这是Android Studio的全新安装,我的build.gradle如下所示:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

相关日志错误的第一行是:

org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.12-all.zip'.
Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'HelloWorld'.
Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'HelloWorld'.
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':classpath'.
Caused by: org.gradle.api.internal.artifacts.ivyservice.ModuleVersionResolveException: Could not resolve com.android.tools.build:gradle:0.12.+.
Caused by: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

项目结构只是具有空白活动的新项目的默认设置:

Project structure screenshot

2 个答案:

答案 0 :(得分:4)

对我来说,它看起来像不兼容的版本。所以这个问题与这个问题有关:Android Studio says to use Gradle 1.10 - but new version is 1.12?

尝试使用gradle 1.10并删除gradle包装器的文件夹。

答案 1 :(得分:-1)

尝试使用mavenCentral()而不是jcenter()

看起来这是一个已知问题.. https://code.google.com/p/android/issues/detail?id=73511