How do I Optimize Imports
on a whole folder or project?
Asked
Active
Viewed 6,538 times
3

Nolan Amy
- 10,785
- 5
- 34
- 45

Program-Me-Rev
- 6,184
- 18
- 58
- 142
-
Ctrl-Alt-O removes unused imports. I am not aware of a bulk add-all-missing-imports option being mapped to a key combination, though it is conceivable that you could set one up. – CommonsWare Jun 06 '15 at 15:20
-
1possible duplicate of [What is the shortcut to Auto import all in Android Studio?](http://stackoverflow.com/questions/16615038/what-is-the-shortcut-to-auto-import-all-in-android-studio) – Nikola Jun 06 '15 at 15:20
3 Answers
9
To optimize imports on the whole project, choose the folder/project you want from the project pane, then press:
Ctrl
Alt
O
on WindowsCtrl
Option
O
on Mac
Optimize Imports
is also available from the right-click menu on projects, folders, files, etc in the project pane.
-
This is it! See also: https://stackoverflow.com/questions/51833539/how-to-delete-all-unused-imports-from-current-project-in-intellij-idea – Nolan Amy Dec 06 '20 at 05:57
2
try the Optimize imports (Option + Ctr + O) option in android studio
go to Preferences --> Keymap -- > and look for "Optimize imports" to find the right shortcut

rahul.ramanujam
- 5,608
- 7
- 34
- 56
2
If Android Studio is still based off of Eclipse, try
Ctrl+Alt+O
Which should be organize / optimize imports.
Ctrl+Alt+F
Runs the auto code formatter.

Matt Clark
- 27,671
- 19
- 68
- 123
-
1Android Studio was never based off of Eclipse. It is based off of JetBrains' IntelliJ IDEA. You may be thinking of the old ADT Plugin for Eclipse, the original IDE support from Google. – CommonsWare Jun 06 '15 at 15:32