0
votes

I have an issue with Dagger and my own generated code.

Assumptions:

  1. I need to generate my own dagger component for UI tests purpose
  2. I have my own Gradle's module for annotation processing which provides dagger component with dependencies. Call this GeneratedTestCoreComponent. This class is generated correctly
  3. GeneratedTestCoreComponent is built at \build\generated\source\kapt\debug\...
  4. GeneratedTestCoreComponent is used in dagger component, smth like this
@Component(modules = [UiTestModule::class],
    dependencies = [GeneratedTestCoreComponent::class])
interface TestUiComponent {}
  1. My annotation processor module is correctly added to gradle
  implementation project(path: ':processor')
  kapt(name: 'processor')

The issue is. During compilation I get below error

TestUiComponent.java:6: error: cannot find symbol
@com.dagger.Component(modules = {com.xxx.xxx.UiTestModule.class}, dependencies = {GeneratedTestCoreComponent.class})

symbol: class GeneratedTestCoreComponent
TestUiComponent.java:8: error: [ComponentProcessor:MiscError] com.dagger.internal.codegen.ComponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public abstract interface TestUiComponent

Additional info. When I copy GeneratedTestCoreComponent class from build directory to src (keeping the same package) and disable my processor, then everything works fine

1
are you using scopes for this ?coroutineDispatcher
Have you tried with testImplementation and kaptTest to add those dependencies to the test variantUser One
@UserOne I've tried androidTestImplementation and kaptAndroidTest but it hasn't helpedDawid Podolak
@StavroXhardha I use own scopes, but I think it is not an issue. As I mentioned in additional info, it works when I copy this class to src dirDawid Podolak
You want your test component for instrumented test not local so, i had a similar issue in local unit test and this post helped Me stackoverflow.com/a/45603080/9884320User One

1 Answers

0
votes

Try changing kapt(name: 'processor') into kapt project(':processor')