-1

How do I Optimize Imports on a whole folder or project?

Nolan Amy
  • 9,896
  • 2
  • 32
  • 43
Program-Me-Rev
  • 5,318
  • 11
  • 47
  • 109
  • 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
  • 1
    possible 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 Answers3

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

rahulrv
  • 5,424
  • 6
  • 30
  • 54
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
  • 24,947
  • 16
  • 62
  • 114
  • 1
    Android 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
1

To optimize imports on the whole project, choose the folder/project you want from the project pane, then press:

  • CtrlAltO on Windows
  • CtrlOptionO on Mac

Optimize Imports is also available from the right-click menu on projects, folders, files, etc in the project pane.

enter image description here

Nolan Amy
  • 9,896
  • 2
  • 32
  • 43
Madhavan
  • 11
  • 1
  • 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