java.lang.NoSuchMethodError on compile
Asked Answered
J

2

5

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.

Jones answered 3/2, 2015 at 23:23 Comment(0)
O
9

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.

Orta answered 4/2, 2015 at 0:25 Comment(3)
first things first: we appreciate and use your stuff everywhere so thanks++ Just wanted to add, this isn't production ready work so there's no expectation of perfect library references, I just was beyond my depth in getting to the bottom of the issue. I will try the workarounds from the referenced issues page for now.Jones
It's apparently fixed in the latest snapshot. Might need to remove dagger 2 from your gradle cache depending on your cache config.Digit
It is fixed, yes. Alternatively, use --refresh-dependencies which is much less destructive.Orta
W
0

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' 
}
Whitewing answered 18/5, 2015 at 8:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.