简体   繁体   中英

java.lang.NoSuchMethodError on compile

I'm trying to compile an Android project unsuccessfully. The error message is:

Execution failed for task ':mobile:_compileAppDebug'.

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:

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

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.

Dagger 2.0-SNAPSHOT depends on an Auto SNAPSHOT which had an API change: 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.

Thus exluding this specific dependency from the apt configuration fixed the problem:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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