How To Auto Import All Class In Android Studio

When you write java code in Android Studio, you always need to import some classes which you used in android application. This article will tell you how to import all used classes automatically.

1. Auto Import Classes In Android Studio.

1.1 For Windows or Linux.

If your android studio is running on Windows or Linux, you can follow below steps.

  1. Click File —> Settings menu item.
    android studio file settings
  2. Click Editor —> General —> Auto Import in the popup dialog.
    android studio file settings editor general auto import
  3. In the right panel, choose All from the Insert imports on paste drop down list. Check Add unambiguous imports on the fly and all other check box. Click OK button.
    android studio aotu import settings
  4. Now when you write or paste a class name in your java source code, android studio will automatically import the class with it’s package.
  5. If you select Ask in Insert imports on paste drop down list. Then android studio will ask you whether import the class or not, you can press Alt+Enter to import it.
    android studio ask to import classes

1.2 For MacOS

If you use MacOS, the only difference is where you can configure above settings.

  1. Just click Android Studio —> Preferences. The subsequent settings are very similar.
    android studio macos configure auto import classes

2. Keymap Shortcut.

There are a lot of shortcuts in android studio which are very useful when you are writing java source code. If you do not remember them, you can find all the shortcuts by below steps.

  1. Click File —> Settings, in the popup dialog click Keymap in left panel.
    android studio keymap shortcut settings
  2. In right panel, you can see all the keymap shortcuts listed in different category. You can read or edit shortcut there also.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.