Compile error while trying to replace dependency in androidTest
See original GitHub issueHalo!
I’ve had a build failure while trying to write a sample project with anvil.
While I used only one AppScope dependencies everything was alright, but when I tried to use ActivityScope for screen subcomponent, I’ve got an error in test component, which was used to test anvil dependency replacement feature:
error: Found conflicting entry point declarations. Getter methods on the component with the same name and signature must be for the same binding key since the generated component can only implement the method once. Found:
public abstract interface TestAppComponent extends com.example.di_demo.AppComponent, com.example.auth_api.AuthDependencies, com.example.auth_impl.di.AuthScreenMergeComponent.ParentComponent, anvil.component.com.example.di_demo.testappcomponent.AuthScreenMergeComponentA.ParentComponent {
^
@org.jetbrains.annotations.NotNull anvil.component.com.example.di_demo.appcomponent.AuthScreenMergeComponentA.SubcomponentFactory anvil.component.com.example.di_demo.appcomponent.AuthScreenMergeComponentA.ParentComponent.authScreenMergeComponentFactory()
@org.jetbrains.annotations.NotNull @Override anvil.component.com.example.di_demo.testappcomponent.AuthScreenMergeComponentA.SubcomponentFactory anvil.component.com.example.di_demo.testappcomponent.AuthScreenMergeComponentA.ParentComponent.authScreenMergeComponentFactory()
Code compiles just okay in ordinary scenario, and fails only in androidTest environment.
Sample project can be found here: https://github.com/midery/di_demo/tree/minimum-reproducible-issue
I will be grateful for any help regarding this issue.
Also, if this project structure is messed up, I would also appreciate any hint on screen component dependencies organization.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
testing - Dependency conflict error in my Android app which ...
To resolve the conflict you first need to figure out the two versions that are conflicting. If you aren't already using the Android...
Read more >Hilt, androidTest build failed in versions >= 2.40.4 · Issue #3162
ComponentProcessor was unable to process 'dagger.hilt.android.internal.testing.root.Default_HiltComponents.SingletonC' because not all of its ...
Read more >Add build dependencies - Android Developers
Learn how to add build dependencies using the Gradle build system in Android Studio.
Read more >Using kapt | Kotlin
If you previously used the Android support for annotation processors, replace usages of the annotationProcessor configuration with kapt .
Read more >Improve the Performance of Gradle Builds
If the change improved build times, make it permanent. If you don't see an improvement, remove the change and try another.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here’s another helpful sample: https://github.com/gpeal/Anvil-Sample
👋 thanks for providing the project! It looks like the issue is that you’re still referencing your main Application class and component in the test code. This means that Dagger/Anvil will attempt to compile the main graph in addition to the test graph since the test component and application are extending their main source counterparts. Making the following changes should get things working:
TestApp.kt:
TestAppComponent.kt: