How to Optimize Imports on All Files in Android Studio
Asked Answered
B

3

5

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

Buenabuenaventura answered 6/6, 2015 at 15:18 Comment(2)
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.Cystocele
possible duplicate of What is the shortcut to Auto import all in Android Studio?Weightless
E
3

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.

Evocator answered 6/6, 2015 at 15:21 Comment(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.Cystocele
M
12

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

Merridie answered 17/12, 2019 at 8:52 Comment(1)
This is it! See also: #51834039Trace
E
3

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.

Evocator answered 6/6, 2015 at 15:21 Comment(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.Cystocele
S
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

Swinish answered 6/6, 2015 at 15:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.