Dagger2 androidTest error duplicate entry: javax/annotation/Generated.class

拟墨画扇 提交于 2019-12-07 07:01:36

问题


I'm using Dagger2 for DI. My project has 2 modules, a :common module which is a library and an :app module which is the actual application.

In the library module I have AndroidApp which extends MultiDexApplication and is inherited in :app module. I have followed Google's dagger2 example to add DI with Dagger2.

Each time I run the app I get the following message as an error:

Android/common/src/main/java/com/common/AndroidApp.java:10: The import com.common.di.DaggerAndroidAppComponent cannot be resolved.

but the weird part is that Android Studio says BUILD SUCESSFULL and the app runs without problems.

When I try to run tests (androidTest) on the :common library module I get the following error:

Error:Execution failed for task ':common:packageAllDebugAndroidTestClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: javax/annotation/Generated.class

I'm assuming there is no connection between these 2 errors, but does anyone have any idea on what's going on and how to fix the tests?


回答1:


After I updated the gradle plugin to 1.2.3 the issues stopped showing up. Weird.



来源:https://stackoverflow.com/questions/29915107/dagger2-androidtest-error-duplicate-entry-javax-annotation-generated-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!