I am using Android Studio 2.2.2; and "Optimize imports on the fly" option is checked.
The problem is, when I'm using a resource without its package; for example sampleString
instead of R.string.sampleString
Android Studio adds the below import
import static com.a.b.R.string.sampleString;
This problem also occurs when I create a new activity, Android Studio imports some random resource to the new created class.
import static com.a.b.randompackage.R;
I can fix this problem by unchecking "Optimize imports on the fly" but I want to keep it checked. Is there any other solution to remove these annoying imports?
Thank you.
Keep "Optimize imports on the fly" option checked.
Unchecking "Show import suggestions for static methods and fields" should do the trick:
Preferences -> Editor -> General -> Auto Import -> Show import suggestions for static methods and fields