Thread
#dagger
    Joan Colmenero

    Joan Colmenero

    2 years ago
    Hello! I'm facing this error whenever I want to create UI tests with Espresso using Dagger
    java.lang.RuntimeException: android.app.Application does not implement dagger.android.HasAndroidInjector
    Any idea, why? It only happens with UI tests, the app runs and everything is injected correctly.
    Jovan

    Jovan

    2 years ago
    Do you use some kind of Test Application class?
    wasyl

    wasyl

    2 years ago
    You probably need to create custom test runner (
    AndroidJUnitRunner
    ) and override
    fun newApplication
    method to call something like
    super.newApplication(cl, TestApplication::class.java.name, context)
    And set
    android.defaultConfig.testInstrumentationRunner = <your custom runner>
    That’s just a quick fyi that it’s usually done, I don’t know if instrumentation tests should use your default class from manifest by default or not
    Joan Colmenero

    Joan Colmenero

    2 years ago
    @Jovan No I do not, shall I?
    @wasyl Do you have a sample where I can guide to do it? I get you but not 100%