Remove unused imports in Android Studio
It is very Simple Just Follow the below step.
- Switch your project in Project Mode.
- Then right-click on project name.
- The final step is to select the Optimize imports from popup menu.
Enjoy!!
You can do it on the fly. You don't need to call (Ctrl+Shift+O) or "Project/Optimize Imports..." each time.
Just set this checkbox in Settings
-> Editor
-> General
-> Auto Import
-> Optimize Imports on the fly
.
On OSX: Preferences
-> Editor
-> General
-> Auto Import
-> Optimize imports on the fly
Simple, right click on your project in Android Studio, then click on the Optimize Imports that should work.
Update
To do same thing which I described above, you can do same just pressing Ctrl+Alt+O, it will optimize imports of your current file and your entire project depends on your selection in a dialog.
Press Ctrl + Alt + O.
A dialog box will appear with a few options. You can choose to have the dialog box not appear again in the future if you wish, setting a default behavior.