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.

jww
  • 97,681
  • 90
  • 411
  • 885
t3rse
  • 10,024
  • 11
  • 57
  • 84

2 Answers2

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.

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
  • 4
    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. – t3rse Feb 04 '15 at 04:08
  • It's apparently fixed in the latest snapshot. Might need to remove dagger 2 from your gradle cache depending on your cache config. – Daniel Lubarov Feb 07 '15 at 01:51
  • 2
    It is fixed, yes. Alternatively, use `--refresh-dependencies` which is much less destructive. – Jake Wharton Feb 07 '15 at 02:10
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' 
}
Soccertrash
  • 1,830
  • 3
  • 28
  • 48