gradle 项目同步失败 android 工作室

gradle project sync failed android studio

我正在尝试在 Android Studio 1.1.0 中设置 nhaarman/ListViewAnimations

来自设置:

将以下内容添加到您的 build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
}

还 Android 工作室说:

Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.

Error:(26, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'X' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

试试这个:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
    compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'
}

将这些行添加到之后:

build.gradle (Module: app)

而不是

build.gradle (Project: app)

错误消失了。

您正在 顶层 build.gradle 文件中添加这些依赖项。

您必须在模块 build.gradle 文件中添加这些行。

root
  build.gradle   //top level
  app
     build.gradle   //module level

尝试删除@arr。为我工作。

//ListView Animations
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'