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.

Dagger does not generate class for TestComponent

See original GitHub issue

I’m trying to run your project in Android studio bug I’m finding a problem. Dagger does not seem to generate the Dagger class for the TestComponent defined in ActivityLauncher. I found the same issue in my own code and I’d like to know if there is anything else I’m supposed to do. ActivityLauncher line 34 shows an error where DaggerActivityLauncher_TestComponent is not found.

DemoApplication app
        = (DemoApplication) fetchInstrumentation().getTargetContext().getApplicationContext();
    TestComponent component = DaggerActivityLauncher_TestComponent.builder()
        .mockClockModule(new MockClockModule())
        .build();
    app.setComponent(component);

Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
chiukicommented, Apr 22, 2015

DaggerActivityLauncher_TestComponent does not get generated until you build the test.

To build the test, open MainActivityTest.java, right click on public class MainActivityTest, and choose Run -> MainActivityTest (the one with the Android icon).

run_test

1reaction
XandrMastercommented, Jun 23, 2019

DaggerActivityLauncher_TestComponent does not get generated until you build the test.

To build the test, open MainActivityTest.java, right click on public class MainActivityTest, and choose Run -> MainActivityTest (the one with the Android icon).

run_test

I spent time a lot for understand that . Thank you so much for help !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dagger not generating components for /test class
Dagger does not, however, generate code for the Component builders in src/test. My main build.gradle: dependencies { classpath 'com.android.
Read more >
Unable to generate TestComponent after update to 2.21+ #1599
We don't run FindBugs on UnitTest classes, so we don't need that annotation. But since it's not stripped dagger fails on that.
Read more >
Dagger annotation processor does not generate classes when ...
Create a Main class whose main method just calls DaggerAppComponent.create() . What is the expected result? The project should be able to compile...
Read more >
Testing with Dagger
It is generally recommended to create a Dagger component in your tests to instantiate objects, whether that is a larger test component for...
Read more >
5 steps to understand Dagger 2 - ProAndroidDev
04 Injection: create a test application class inherited from DaggerTutoApplication. We will instantiate our test component there, before injecting it into the ...
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