简体   繁体   English

Gradle项目同步失败的Android Studio

[英]gradle project sync failed android studio

I'm trying to setup nhaarman/ListViewAnimations inside of Android Studio 1.1.0. 我正在尝试在Android Studio 1.1.0内设置nhaarman / ListViewAnimations

From Setup: 从安装程序:

Add the following to your build.gradle: 将以下内容添加到您的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'
}

yet Android Studio says: 但Android Studio表示:

Gradle project sync failed. Gradle项目同步失败。 Basic functionality (eg 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>

After adding those lines to: 将这些行添加到后:

build.gradle (Module: app)

instead of 代替

build.gradle (Project: app)

the error is gone. 错误消失了。

You are adding these dependencies in the top level build.gradle file. 您将这些依赖项添加到顶级 build.gradle文件中。

You have to add these lines in the module build.gradle file. 您必须将这些行添加到模块build.gradle文件中。

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

Try this: 尝试这个:

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'
}

Try removing @arr. 尝试删除@arr。 worked for me. 为我工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM