Reputation: 4396
Is there any way/setting in Android Studio to report the unused imports in java files as error?
In Eclipse, lint reported this as error pretty easily.
Upvotes: 3
Views: 1987
Reputation: 1150
For Android Studio Arctic Fox | 2020.3.1 Patch 4, follow this Android Studio -> Preferences -> Editor -> General -> Auto Import
Upvotes: 1
Reputation: 89
First remove references of these imports from the code.
Then you can use this shortcut
ALT + CTRL + O
Upvotes: 1
Reputation: 76
Applies to Android Studio and IntelliJ
You could go to File/Settings
then browse to Editor/Inspections/Import.
Change Severity of Unused Import to Error
Upvotes: 6
Reputation: 18978
try this.
its automatically remove unused imports
yourProject --> Right Click --> Optimize Imports
lint : its also show unused imports in java files as error
yourProject --> Right Click --> Analize --> Inspect Code
Upvotes: 1