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: @Provides methods may not override another method.

See original GitHub issue

I want to use @Provides in-conjunction with @Override. but dagger says error: @Provides methods may not override another method.. So I wrote below fix

@Override
protected X getX() {
    return new X();
}

@Provides
X provideX() {
    return getX();
}

Is this a good approach ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
pinkaseycommented, Dec 31, 2019

I got here by googling the error message (of course). So this issue is important, even while closed.

I’ll add my 2 cents: here’s an explanation of a common use case that would naturally lead to inheritance of Modules, and the recommended way to implement it: https://dagger.dev/testing.html

1reaction
saurabhkpatelcommented, Jan 29, 2019

@theapache64 how did you solve this problem? do you have any sample project which you could share?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you override a module/dependency in a unit test with ...
In our tests we want to provide StringHolder with "Test string". ... Error:(24, 21) error: @Provides methods may not override another method.
Read more >
Any way to override bindings? - Google Groups
Hi there. We have a parent project and a child project. The child project is a customization of the parent project, where some...
Read more >
Testing with Dagger
Do not override bindings by subclassing modules · Using a module subclass cannot change the static shape of the binding graph: it cannot...
Read more >
Chapter 8. Classes - Oracle Help Center
Any of C's superclasses has an abstract method declared with package access, and there exists no method that overrides the abstract method from...
Read more >
Dagger - Square Open Source
Fix the problem either by adding an @Provides -annotated method for Executor , or by marking the module as incomplete. Incomplete modules are...
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