mbo
mbo

Reputation: 4691

Change "unambiguous" auto import of android.util.Log in Android Studio

I have a custom logging class which is also called Log and has the static methods v(), e() and so on.

Now when I'm typing Log.e( the auto import will import android.util.Log on the fly. An option is to disable Add unambiguous imports on the fly but then it'll not import anything.

So can the automatic import be changed to always import my Log class?

Upvotes: 2

Views: 585

Answers (2)

MatPag
MatPag

Reputation: 44813

The easiest way is to start typing the class name, Like

Log.d

Then when the suggestion import popup appears, press ALT + ENTER and another side popup will appear with fast exclusion rules based on package depth like in the image below.

fast esclusions

Then if you want rollback the exclusion or change the scope (IDE/Project) you can go in the Auto Import panel and change accordingly per your needs like in the image below:

enter image description here

Tested on AS 3.0 Beta 7

Upvotes: 2

Luca Nicoletti
Luca Nicoletti

Reputation: 2397

Open Android Studio settings, go to

Editor > General > Auto Imports

In the section named Exclude from Import and Completion add android.util.Log.

After that, when you start typing Log the suggestions will start with your custom class.


EDIT: don't forget to set it to Project. So for other projects it won't be excluded.

Upvotes: 2

Related Questions