It seems that Dagger 2.11 is not compatible with Guava 22.0-android due to the loss of methods like SetMultimap.forEach. When compiling an Android project with both libraries I'm receiving the following error. Will there be an effort to stay compatible with the new *-android line of Guava releases?
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodError: com.google.common.collect.SetMultimap.forEach(Ljava/util/function/BiConsumer;)V
The annotation processor classpath should be separate from the compile time classpath. I presume you're getting this error because you have a compile dep on guava-android; if so, can you add an annotationProcessor 'com.google.guava:guava:22.0 dep too? If that fixes it, we should update our docs
That does fix it, thanks.
I think you could also set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath to false.
Yes, that works as well. And it looks like it may be the default option starting in Android Studio/Gradle plugin 3.0.
Any idea how to fix this error when using kapt? including guava as kapt "dependency" does not work.
Apparently my usage of resolutionStrategy.force "com.google.guava:guava:22.0-android"
caused the issue for me.
It was just my mistake.
See below @JakeWharton 's comment.
In my case.
I followed solution by suggested @ronshapiro .
I added annotationProcessor 'com.google.guava:guava:22.0 too. but It doesn't solved my error.
So I was curious the SetMultimap.forEach and I searched javadoc but It was only exist in non android guava.
````java
/**
To loop over all keys and their associated value collections, write
So I modified guava version 23.0-android to 23.0.
It was worked.
But It still exsits problem in older than java8 android versions...
The processor runs at build time on your computer JVM and doesn't have
anything to do with the Android versions the app runs on. The annotation
processor should not be using the -android version of Guava.
On Sun, Sep 10, 2017, 11:33 AM galcyurio notifications@github.com wrote:
In my case.
I followed solution by suggested @ronshapiro
https://github.com/ronshapiro .
I added annotationProcessor 'com.google.guava:guava:22.0 too. but It
doesn't solved my error.So I was curious the SetMultimap.forEach and I searched javadoc but It
was only exist in non android guava./** * Performs the given action for all key-value pairs contained in this multimap. If an ordering is * specified by the {@code Multimap} implementation, actions will be performed in the order of * iteration of {@link #entries()}. Exceptions thrown by the action are relayed to the caller. * *
To loop over all keys and their associated value collections, write * {@code Multimaps.asMap(multimap).forEach((key, valueCollection) -> action())}. * * @since 21.0 */
default void forEach(BiConsumer super K, ? super V> action) {
checkNotNull(action);
entries().forEach(entry -> action.accept(entry.getKey(), entry.getValue()));
}So I modified guava version 23.0-android to 23.0.
It was worked.But It still exsits problem in older than java8 android versions...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/dagger/issues/753#issuecomment-328350351, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEZK9DgaK9JoH6RNu4tqsP3GOCufVks5shAFQgaJpZM4NoxR0
.
Thanks. @JakeWharton
I just added same version before...
silly my brain...
guavaVersion = '23.0-android'
compile "com.google.guava:guava:$rootProject.guavaVersion"
annotationProcessor "com.google.guava:guava:$rootProject.guavaVersion"
And I fixed the problem as below.
guavaVersion = '23.0'
compile "com.google.guava:guava:$rootProject.guavaVersion-android"
annotationProcessor "com.google.guava:guava:$rootProject.guavaVersion"
Yep. That looks great.
On Sun, Sep 10, 2017, 11:50 AM galcyurio notifications@github.com wrote:
Thanks. @JakeWharton https://github.com/jakewharton
I just added same version before...
silly my brain...guavaVersion = '23.0-android'
compile "com.google.guava:guava:$rootProject.guavaVersion"
annotationProcessor "com.google.guava:guava:$rootProject.guavaVersion"And I fixed the problem as below.
guavaVersion = '23.0'
compile "com.google.guava:guava:$rootProject.guavaVersion-android"
annotationProcessor "com.google.guava:guava:$rootProject.guavaVersion"—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/google/dagger/issues/753#issuecomment-328351401, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEER_YEn59vgDAGy2qPXDLxqO1NECpks5shAUpgaJpZM4NoxR0
.
Most helpful comment
The annotation processor classpath should be separate from the compile time classpath. I presume you're getting this error because you have a
compiledep on guava-android; if so, can you add anannotationProcessor 'com.google.guava:guava:22.0dep too? If that fixes it, we should update our docs