To optimize imports (to remove unused imports ) use Ctrl + Alt + O.
Simple, right click on your project in Android Studio, then click on the Optimize Imports that should work.
In Android Studio, there is a way to automatically organize imports as you type. If you are on a Mac, go to Android Studio -> Preferences (on Windows I think it's under File -> Settings), and then under Editor -> Auto Import, you can change the settings to look like this.
Simple, right click on your project in Android Studio, then click on the Optimize Imports that should work.
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.
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
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.
It is very Simple Just Follow the below step.
Enjoy!!
Sorry for the late answer.. For mac users command + option + o Try this.. It is working for me..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With