Closed alvindizon closed 2 years ago
Thanks for the report on this. I think we can suppress this in the generated code by adding a @SuppressLint
annotation. In this case, unless you are seeing bugs with the theme, suppressing seems like the right call since we are implementing getLayoutInflater()
to sneak our Hilt context wrapper in so we can't do what the lint suggests and call it.
Hi @Chang-Eric , thanks for your response. Apologies but I don't quite understand what you're saying about adding the annotation--we can't add it to generated code, or are you talking about annotating my Fragment both with @SuppressLint
and @AndroidEntryPoint
?
I meant I will submit a change to Hilt to add it =)
Ah got it, @Chang-Eric thanks :)
This will be fixed when that is change is released. It ended up that instead of suppressing the warning, we should have been using cloneInContext(). Thanks for bringing this to our attention!
I have a class that extends from DialogFragment that is annotated with
@AndroidEntryPoint
, something like this:I upgraded my project's Android Gradle Plugin to
7.2.0-alpha06
and Gradle to7.3.3
, and runninglintRelease
produces this error:Checking the generated class, I can see this:
I'm using version
2.40.5
of Dagger btw. I also have other classes that extend fromFragment
, ~but they do not get flagged by lint, even if their generated classes also useLayoutInflater.from(FragmentComponentManager.createContextWrapper(inflater, this))
~. Now I'm not sure this is the correct place to bring this up, feel free to close this if this is not appropriate, but I'd like to bring this to your attention as I'm not sure how to handle this. I'm thinking of temporarily silencing this error via adding this issue tolint.xml
.edit: apologies, other classes extending from Fragment also trigger this lint error. I have silenced this error by adding the
UseGetLayoutInflater
issue in ourlint.xml
.