Improve error message for transitive types
See original GitHub issueSay you have 3 modules, :app
, :libraryA
and :libraryB
.
:app
depends on :libraryA
which in turn depends :libraryB
using the implementation
configuration.
If :libraryB
has some dagger modules or components you can get this cryptic error message:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
Running with --stacktrace
gives slightly more information:
java.lang.IllegalArgumentException: com.example.libraryb.SomeType does not represent a declared type
at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:948)
at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:939)
at jdk.compiler/com.sun.tools.javac.code.Type$ErrorType.accept(Type.java:2386)
at dagger.shaded.auto.common.MoreTypes.asDeclared(MoreTypes.java:579)
at dagger.internal.codegen.base.Keys$1.visitDeclared(Keys.java:85)
at dagger.internal.codegen.base.Keys$1.visitDeclared(Keys.java:62)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1151)
at dagger.internal.codegen.base.Keys.isValidImplicitProvisionKey(Keys.java:61)
at dagger.internal.codegen.base.Keys.isValidImplicitProvisionKey(Keys.java:46)
at dagger.internal.codegen.validation.InjectBindingRegistryImpl.getOrFindProvisionBinding(InjectBindingRegistryImpl.java:300)
at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.lookUpBindings(BindingGraphFactory.java:410)
at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.resolve(BindingGraphFactory.java:919)
at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.resolveDependencies(BindingGraphFactory.java:934)
at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.resolveMembersInjection(BindingGraphFactory.java:877)
at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.access$1300(BindingGraphFactory.java:310)
at dagger.internal.codegen.binding.BindingGraphFactory.lambda$createLegacyBindingGraph$4(BindingGraphFactory.java:214)
at dagger.internal.codegen.binding.BindingGraphFactory.createLegacyBindingGraph(BindingGraphFactory.java:211)
at dagger.internal.codegen.binding.BindingGraphFactory.createLegacyBindingGraph(BindingGraphFactory.java:240)
at dagger.internal.codegen.binding.BindingGraphFactory.create(BindingGraphFactory.java:118)
at dagger.internal.codegen.ComponentProcessingStep.processRootComponent(ComponentProcessingStep.java:115)
at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:93)
at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:53)
at dagger.internal.codegen.validation.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:51)
at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:185)
at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:48)
at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:34)
at dagger.internal.codegen.statistics.DaggerStatisticsCollectingProcessingStep.process(DaggerStatisticsCollectingProcessingStep.java:52)
at dagger.shaded.auto.common.BasicAnnotationProcessor$ProcessingStepAsStep.process(BasicAnnotationProcessor.java:495)
at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:228)
at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:208)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:161)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980)
... 37 more
This is of course an error in the setup and :app
should either depend on :libraryB
directly or you should use api
but it’s very difficult to determine what module is causing issue. You see which type it related too but not really which file is being processed.
In any case I think there is room improvement here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:34
- Comments:10
Top Results From Across the Web
How to Identify and Fix Flutter's Transitive Dependency Error
Solution 2. Explicitly list the corrected transitive dependency. This solution corrects the transitive dependency explicitly, but you will need ...
Read more >Why does tsc give so cryptic errors when leaking transitive ...
My question is, is there a way to detect these earlier on my independent module B? I recall sometimes getting errors when modules...
Read more >Transitive relation - Wikipedia
In mathematics, a relation R on a set X is transitive if, for all elements a, b, c in X, whenever R relates...
Read more >Schema Registry API Reference | Confluent Documentation
All API endpoints use a standard error message format for any requests that return ... If compatibility is set to one of the...
Read more >Add build dependencies - Android Developers
On this page; Dependency types. Native dependencies. Dependency configurations. Add annotation processors; Exclude transitive dependencies.
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 FreeTop 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
Top GitHub Comments
If you’re using Hilt (with Gradle) the solution is to use the Hilt Gradle plugin and then enable the
aggregating task
in yourbuild.gradle
modules:@bcorso Thanks for the quick resolution. It worked!! now I removed all other dependencies for ;app module. I feel Hilt documentation is misleading as first line itself says “The Gradle module that compiles your Application class needs to have all Hilt modules and constructor-injected classes in its transitive dependencies.”