简体   繁体   English

编译时的java.lang.NoSuchMethodError

[英]java.lang.NoSuchMethodError on compile

I'm trying to compile an Android project unsuccessfully. 我正在尝试编译Android项目失败。 The error message is: 错误消息是:

Execution failed for task ':mobile:_compileAppDebug'. 任务':mobile:_compileAppDebug'的执行失败。

java.lang.NoSuchMethodError: com.google.auto.common.MoreTypes.asTypeElements(Ljavax/lang/model/util/Types;Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableSet; java.lang.NoSuchMethodError:com.google.auto.common.MoreTypes.asTypeElements(Ljavax / lang / model / util / Types; Ljava / lang / Iterable;)Lcom / google / common / collect / ImmutableSet;

Here are my module's gradle dependencies in which I specify a number of libraries including google Auto: 这是我的模块的gradle依赖项,其中我指定了许多库,包括google Auto:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':library')
    compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
    provided 'com.google.auto.value:auto-value:1.0-rc1'
    apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
    provided 'org.glassfish:javax.annotation:10.0-b28' 
    compile 'com.jakewharton:butterknife:6.1.0' 
    compile 'com.f2prateek.dart:dart:1.1.0'
}

When I looked at the dependencies I thought I just needed google auto value since that is where the missing method resides but adding the provided does not resolve the issue. 当我查看依赖项时,我认为我只需要谷歌自动值,因为这是丢失方法所在的位置,但添加提供的并不能解决问题。

The project gradle file includes the retrolambda plugin 项目gradle文件包含retrolambda插件

dependencies {
    classpath 'me.tatarka:gradle-retrolambda:2.5.0'
    classpath 'com.android.tools.build:gradle:1.0.1'
    classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
    classpath 'io.fabric.tools:gradle:1.+'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}

Can anyone help me identify which dependencies cause the compile error? 任何人都可以帮我确定哪些依赖项导致编译错误? Interestingly enough, when I copy the gradle files into an empty project everything runs fine. 有趣的是,当我将gradle文件复制到一个空项目时,一切运行正常。

Dagger 2.0-SNAPSHOT depends on an Auto SNAPSHOT which had an API change: https://github.com/google/dagger/issues/113 Dagger 2.0-SNAPSHOT取决于具有API更改的自动SNAPSHOT: https//github.com/google/dagger/issues/113

This is perfectly normal and acceptable thing for libraries which are under development. 对于正在开发的图书馆来说,这是完全正常和可接受的事情。 If you cannot tolerate an occasional broken build, do not depend on non-release versions in a manner that can change at any time without warning. 如果您不能容忍偶尔出现破坏的构建,请不要在没有警告的情况下随时更改非发布版本。

I ran in a similar issue. 我遇到了类似的问题。 Some libary I'm using bundles Guava within the jar file. 一些库我在jar文件中使用捆绑式Guava。

Thus exluding this specific dependency from the apt configuration fixed the problem: 因此,从apt配置中排除这种特定的依赖性修复了问题:

configurations {
  apt.exclude module: 'artifactId-Of-Library' 
}

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

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