Organizing Imports


The Organize Imports function does not seem to work for me. I am running Android Studio 1.0.2, and I believe the function has evolved to be named “Optimize Imports”; the keyboard shortcut is now Ctrl+Alt+O.

In any event, when attempting this function on either Listing 1.8 or Listing 1.10 ( it appears to yield no result; the errors remain. For 1.8 I ended up just manually adding the ‘import android.widget.Button;’ import statement at the top to get past it after trying everything else, but now I’m stuck again at 1.10. Any ideas?

So far I’ve checked and rechecked for typos, run both Clean Project and Rebuild Project (though I’m not precisely certain what either utility actually does), and rebuilt the project from scratch, all to no avail. Thanks for any assistance.


I believe by default, IntelliJ/Android Studio does not automatically import required classes, requiring an Alt+Enter shortcut to bring up the import menu for each required import. I found it was much easier to turn on the setting to automatically import classes on the fly.

IDE Settings -> Editor -> Auto Import -> Optimize imports on the fly