简体   繁体   中英

Espresso Dagger 2.11

Struggling to use Dagger 2 for UI testing powered by Espresso. I'm trying to generate a dedicated test @Component under androidTest directory but getting this error:

Error:Bad service configuration file, or exception thrown while constructing
Processor object: javax.annotation.processing.Processor: 
Provider dagger.android.processor.AndroidProcessor could not be instantiated:
java.lang.NoClassDefFoundError: com/google/common/collect/SetMultimap

Here's how dependencies look like:

androidTestCompile "com.google.dagger:dagger:2.11",
androidTestCompile "com.google.dagger:dagger-android:2.11"
androidTestCompile  "com.google.dagger:dagger-android-support:2.11"
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.11"
androidTestAnnotationProcessor "com.google.dagger:dagger-android-processor:2.11"

Have anyone faced with this and has a clue how to solve it?

Thanks.

Found a solution, basically, the culprit was lying in build.gradle just a few lines below:

configurations {
   ...

   androidTestCompile.exclude group: 'com.google.guava', module: 'guava'

   ...
}

This line was excluding some useful stuff from Dagger library and preventing it from being compilable.

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