31

I want to turn off wild cart import in java class import.

For example if I am importing java.util package's any class then it will import whole java package like java.util.*. So how can I stop in android studio 3.1.1.

Here is screenshot from my problem.

enter image description here

I just used only two classes form this package named Locale and Calendar. But still I have to import whole package so want to stop importing whole package and just import on this two class default.

Also tried this reference link but not working for me : https://stackoverflow.com/a/3348855/5697244

Note: I am using kotlin language as development.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Sagar Kacha
  • 8,338
  • 4
  • 18
  • 27

2 Answers2

77

Finally got answer by re-search:

Simple steps to disable wildcart import in in Android Studio with Kotlin. Steps as listed below.

  1. In settings>code style>java as mentioned in below screen.

enter image description here

  1. In java import tab apply changes as given in below screen

enter image description here

  1. Also in kotlin tab apply changes as given in below changes

enter image description here

Note : Don't forgot to remove all packages form "packages to use import with *" section in kotlin tab.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Sagar Kacha
  • 8,338
  • 4
  • 18
  • 27
  • 1
    Thanks for referencing Kotlin, I was pulling my hair apart as I made the changes only to the Java Coding Style imports. – Skynet Jun 24 '20 at 13:00
3

Look under Settings -> Code Style -> Kotlin -> Packages to Use Import with '*' (note, Kotlin, not Java as in the linked question). I've just checked and it does include java.util.* at my machine and I didn't edit it before.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487