Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add imports with Android LintFix

Tags:

android

lint

I am using Android LintFix (see slide 119 or code examples) and I have managed to do fixes for the function, however it does not seem to be possible to add imports like Kotlin @Deprecated annotation. Is it possible to do somehow or should I rely on the IDE for auto-import?

like image 807
Diego Gómez Olvera Avatar asked Aug 30 '25 18:08

Diego Gómez Olvera


1 Answers

Thanks to Mark Prengemann who indicated me the solution:

Using fully qualified names with reformat(true) and shortenNames():

 LintFix.create().replace()                    
 .text("<original>").with("<correction with fully qualified entities>")
 .shortenNames()
 .reformat(true)
 .build()
like image 139
Diego Gómez Olvera Avatar answered Sep 02 '25 07:09

Diego Gómez Olvera