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 generates invalid code

See original GitHub issue

Dagger generates invalid code if auto-value annotations are present, but auto-value processor is not configured as an annotation processor. This can lead to compile failures that are hard to understand.

Also the error message @AutoAnnotation is a necessary dependency if @MapKey(unwrapValue = false). Add a dependency on com.google.auto.value:auto-value:<current version> in MapKeyValidator is misleading, because

  • AutoAnnotation is not in artifact auto-value but in auto-value-annotations
  • Having AutoAnnotation on the classpath does not imply that auto-value is also working as an annotation processor

See demo

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
bcorsocommented, Dec 17, 2021

Sorry, I considered this more of an issue with improper setup of auto-value (on the user side) due to a misleading error message (on the Dagger side). Understandably, you could argue that the user shouldn’t have to add these dependencies manually, but this is currently working as intended to avoid adding the auto-value dependencies to all users who aren’t using the feature.

That said, I’m currently discussing with the team on ways we can improve this experience, e.g. by reevaluating adding the auto-value dependency (which should be pretty small now that the annotations have their own artifact), shading auto-value into Dagger, or just reimplementing that part ourselves.

I’m happy to leave this issue open until we make a decision on that.

0reactions
h908714124commented, Dec 17, 2021

Seems like this ticket was closed, but the problem was not fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dagger 2 component not generated - Stack Overflow
If Dagger2 can not generate its components it means that your code have some errors with Scopes/Modules. Check our your @Provides/Inject ...
Read more >
Deep dive into Dagger generated code (part 1) - ProAndroidDev
In this blog post, we will convert the Dagger generated code from Java to Kotlin to understand how @Inject constructors and @Provides works....
Read more >
Dagger 2 Generated Code - Medium
Basically, Dagger 2 generates a bunch of factories for your provided dependencies.
Read more >
Dependency Injection with Dagger 2 - CodePath Cliffnotes
Android Studio by default will not allow you to navigate to generated Dagger 2 code as legitimate classes because they are not normally...
Read more >
Android - Dagger
Dagger 2 is the first to implement the full stack with generated code. ... public class CoffeeApp { public static void main(String[] args)...
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