question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error: Processor option -Adagger.validateTransitiveComponentDependencies needs a value

See original GitHub issue

I’ve a network module with:


@Module(includes = [ApiProviders::class])
abstract class ApiModule

and

@Module
object ApiProviders {

    @Provides
    @Singleton
    fun provideHttpLoggingInterceptor(): HttpLoggingInterceptor {
        return HttpLoggingInterceptor().apply {
            level = if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.BASIC
        }
    }
...
}

My app module with:

@Component(modules = [ApiModule::class, ...])
@Singleton
interface AppComponent : AndroidInjector<...App> {

    @Component.Factory
    interface Factory : AndroidInjector.Factory<...App> {
        override fun create(@BindsInstance instance: ...App): AppComponent
    }
}

and in its build.gradle.kts I’ve replaced this script with:

gradle.projectsEvaluated {
    tasks.withType<JavaCompile> {
        options.compilerArgs.add("-Xmaxerrs=500")
        options.compilerArgs.add("-Adagger.validateTransitiveComponentDependencies=ENABLED")
    }
}

But or am I misusing it or something is missing because now I get this error upon ./gradlew assembleDebug --stacktrace:

> Task :app:kaptDevDebugKotlin
error: cannot access HttpLoggingInterceptor
  class file for okhttp3.logging.HttpLoggingInterceptor not found
  Consult the following stack trace for details.
cannot access HttpLoggingInterceptor

  com.sun.tools.javac.code.Symbol$CompletionFailure: class file for okhttp3.logging.HttpLoggingInterceptor not found .../di/AppComponent.java:8: error: [ComponentProcessor:MiscError] 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 AppComponent extends dagger.android.AndroidInjector<App> {
warning: The following options were not recognized by any processor: '[-Adagger.validateTransitiveComponentDependencie, dagger.validateTransitiveComponentDependencie, kapt.kotlin.generated]'
The following options were not recognized by any processor: '[-Adagger.validateTransitiveComponentDependencie, dagger.validateTransitiveComponentDependencie, kapt.kotlin.generated]'

> Task :app:kaptDevDebugKotlin FAILED
                ^

If I revert the build.gradle.kts replace, project compiles and everything is OK. What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
bcorsocommented, Sep 17, 2020

FWIW, it looks like your approach also works if you pass the value like this:

kapt {
    javacOptions {
        ...
        option("-Adagger.validateTransitiveComponentDependencies=DISABLED")
    }
}
0reactions
GuilhEcommented, Dec 22, 2020

Hello @jbluntz , My configuration is simpler than yours, I’ve a module App and only this module includes other modules (A, B and C), example:

Module A

@Module(includes = [AModuleProviders::class])
abstract class AModule

@Module
object AModuleProviders {

    @Provides
    @Singleton
    fun provideString String = "abc"

Module App

@Component(modules = [AModule::class, ...])
@Singleton
interface AppComponent : AndroidInjector<App> {

    @Component.Factory
    interface Factory : AndroidInjector.Factory<App> {
        override fun create(@BindsInstance instance: App): AppComponent
    }
}

I even end up not using this flag anymore 🤔 . I was using it like this:

    kapt {
        javacOptions {
            option("-Xmaxerrs", 500)
//            option("-Adagger.validateTransitiveComponentDependencies=DISABLED")
        }
    }

Have you tried with Hilt?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dagger 2 changelog - Awesome Android | LibHunt
Sets the default value for experimentalDaggerErrorMessages back to disabled since it ... The old error message format can still be used by setting...
Read more >
google/dagger dagger-2.41 on GitHub - NewReleases.io
This release fixes a recently noticed, but long-standing bug (#3136) where Dagger's processors may silently miss a scope/qualifier on a binding if the ......
Read more >
Releases · google/dagger · GitHub
A fast dependency injector for Android and Java. Contribute to google/dagger development by creating an account on GitHub.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found