Gradle - 评估根项目'*'时出现问题。 >无法在根项目'*'上找到参数[*]的方法compile()

时间:2015-03-12 16:25:50

标签: android gradle

我正在使用eclipse Luna来开发我的Android应用。我不知道为什么错误信息会一再显示。填写build.gradle中的依赖项并在终端中运行gradle build后收到此错误消息。

的build.gradle

dependencies {
    compile 'com.lorentzos.swipecards:library:1.0.8@aar'
}

错误消息

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/MNurdin/Documents/Github/Swipecards/example/src/main/build.gradle' line: 2

* What went wrong:
A problem occurred evaluating root project 'main'.
> Could not find method compile() for arguments [com.lorentzos.swipecards:library:X.X.X@aar] on root project 'main'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.34 secs

项目:https://github.com/datomnurdin/Swipecards

请指教。谢谢。

4 个答案:

答案 0 :(得分:2)

改为:

compile 'com.lorentzos.swipecards:library:1.0.8'

答案 1 :(得分:1)

当我尝试使用gradle 2.6构建使用gradle 2.3构建的项目时,我遇到了错误。确保版本相同。

答案 2 :(得分:0)

编译任务由java插件定义。但是,由于您没有将它包含在根项目中,因此它不存在,因此gradle不知道如何处理它。 要解决它,您可以:

  1. 将java插件应用于根项目。这种方法的缺点是这个插件会自动包含在你的所有子项目中,在某些情况下可能是不受欢迎的,并且默认情况下会为这个项目创建一个空的jar。
  2. 自己定义一个虚拟空编译任务,这样gradle就会很开心。

答案 3 :(得分:0)

compiledependency configuration中的from the Java Plugin

Android Gradle插件在底层应用了Java插件。我在您的Gradle脚本中没有看到Android插件已应用。我认为您可能会缺少应用Android Gradle插件的module-level build configuration,该插件会将dependencies.compile(...)添加到DSL。

相关问题