问题
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.
回答1:
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
回答2:
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
回答3:
First remove references of these imports from the code.
Then you can use this shortcut
ALT + CTRL + O
来源:https://stackoverflow.com/questions/35357679/report-unused-imports-as-error-in-android-studio-or-intellij