Report unused imports as error in Android Studio or IntelliJ

天大地大妈咪最大 提交于 2021-01-28 20:29:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!