'Report unused imports as error in Android Studio or IntelliJ
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.
Solution 1:[1]
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
Solution 2:[2]
First remove references of these imports from the code.
Then you can use this shortcut
ALT + CTRL + O
Solution 3:[3]
For Android Studio Arctic Fox | 2020.3.1 Patch 4, follow this Android Studio -> Preferences -> Editor -> General -> Auto Import
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dhaval Parmar |
| Solution 2 | abdullahicyc |
| Solution 3 | leeCoder |

