-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Hilt] Lint flags generated DialogFragment class with "Error: Use of LayoutInflater.from... detected. Consider using getLayoutInflater() instead" #3222
Comments
Thanks for the report on this. I think we can suppress this in the generated code by adding a |
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 |
I meant I will submit a change to Hilt to add it =) |
Ah got it, @Chang-Eric thanks :) |
…t(). This is more correct and removes the need for overriding getSystemService() in our ContextWrapper, however, since users may be depending on this if they used LayoutInflater.from() leaving in that getSystemService() override. Fixes #3222. RELNOTES=Fix #3222. Generated fragment code previously would cause a Lint issue around LayoutInflater.from(). PiperOrigin-RevId: 430493436
…t(). This is more correct and removes the need for overriding getSystemService() in our ContextWrapper, however, since users may be depending on this if they used LayoutInflater.from() leaving in that getSystemService() override. Fixes #3222. RELNOTES=Fix #3222. Generated fragment code previously would cause a Lint issue around LayoutInflater.from(). PiperOrigin-RevId: 430493436
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 use. 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 toLayoutInflater.from(FragmentComponentManager.createContextWrapper(inflater, this))
lint.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
.The text was updated successfully, but these errors were encountered: