google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.45k stars 2.02k forks source link

multi-dex error with dagger-2.10 #717

Closed KaranbeerKaur closed 7 years ago

KaranbeerKaur commented 7 years ago

Previously I was using dagger 2.4 version and when I try to generate code coverage by running android gradle task createDebugCoverageReport at that time I was getting this([http://stackoverflow.com/questions/42714259/error-when-generating-code-coverage-report-for-androidtest-instrumented-testcase]) error.

Now I update dagger version to 2.10 and app is multi-dex application, But I am getting below error Error:Execution failed for task ``` ':app:transformClassesWithMultidexlistForDebugAndroidTest'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.multidex.ClassReferenceListBuilder with arguments {/ Users/sample-app/app/build/intermediates/multi-dex/androidTest/debug/componentClasses.jar /Users/ sample-app/app/build/intermediates/transforms/jarMerging/androidTest/debug/jars/1/1f/combined.jar}


how can I solve dagger error with code coverage generation. 
ronshapiro commented 7 years ago

This isn't clear to me to be a dagger issue. Maybe try posting this on StackOverflow, which is better for questions

KaranbeerKaur commented 7 years ago

@ronshapiro But this error is related to dagger2.4

java.lang.NoClassDefFoundError: **dagger.shaded.auto.common.BasicAnnotationProcessor**
  at java.lang.Class.classForName(Native Method)
  at java.lang.Class.forName(Class.java:324)
  at android.support.test.internal.runner.TestLoader.doLoadClass(TestLoader.java:92)
  at android.support.test.internal.runner.TestLoader.loadIfTest(TestLoader.java:113)
  at android.support.test.internal.runner.TestRequestBuilder.loadClassesFromClassPath(TestRequestBuilder.java:801)
  at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:747)
  at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:354)
  at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:260)
   at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1970)
tbroyer commented 7 years ago

What Ron means is that it's not a bug in Dagger itself, but rather has to do with how you're using it; so StackOverflow is a better place to seek for help in fixing your project.

KaranbeerKaur commented 7 years ago

@tbroyer I have already posted this on StackOverflow http://stackoverflow.com/questions/42714259/error-when-generating-code-coverage-report-for-androidtest-instrumented-testcase but didn't get any success. you have better idea on dagger, if you can suggest to solve issue with dagger.shaded.auto.common.BasicAnnotationProcessor. can please update coffee example having test cases in espresso and mockito and with "testCoverageEnabled true" giving code coverage for coffee example, so that we can refer that example and can cross check issue. It will be very helpful. thanks!