【问题标题】:gradle project sync failed android studiogradle项目同步失败android studio
【发布时间】:2015-03-05 16:56:18
【问题描述】:

我正在尝试在 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 Studio 说:

Gradle 项目同步失败。基本功能(例如编辑、 调试)将无法正常工作。

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>

【问题讨论】:

  • 一个月前我已经导入了这个项目。您是否尝试点击 Apply Gradle Plugin?
  • 我做了,我得到了插件列表,但 Gradle 不在列表中。

标签: android gradle android-gradle-plugin


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

    将这些行添加到:

    build.gradle (Module: app)

    而不是

    build.gradle (Project: app)

    错误消失了。

    【讨论】:

      【解决方案3】:

      试试这个:

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

      【讨论】:

        【解决方案4】:

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

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

        【讨论】:

          猜你喜欢
          • 2014-07-03
          • 2014-04-04
          • 1970-01-01
          • 1970-01-01
          • 2015-03-22
          • 2014-09-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多