I am working on a project in Android studio. Suddenly, auto import stopped working in android studio for Android classes, like Android.widgets.Textview, etc. In my settings, auto import is enabled. If I write import android.widget.textview, then TextView shows up in the auto import box.
-
Try option + enter if you are using Android Studio on MacOSX – Wesley Jun 25 '14 at 10:32
-
1Only for android.xxxxx.xxxxxx i have to copy -paste import lines – Minto Jun 25 '14 at 10:35
7 Answers
The problem was with android studio indexing.
Follow the steps..
Go to 'File' > 'Invalidate caches/restart'
Now the studio will shut down and restart. Now indexing begins. On completion of indexing you will find the Suggestion boxes with every possible suggestions.

- 2,004
- 1
- 15
- 19
-
4
-
-
Invalidate/restart wasn't working, somehow the "Add unambiguous imports on the fly" was unchecked despite it working not 2-3 updates ago. Ticked the box and now it's working again. – the_dude_abides May 22 '17 at 22:51
-
-
1thanks so much, i am using android studio 3.0.1 and the auto import still doesnt work as intended – lollerskates Dec 31 '17 at 09:07
-
For me, the problem was that "Show import popup" was not checked at File > Settings > Editor > General > Auto Import > Java.

- 592
- 6
- 17
-
1thanks for location. my problem was Excluding import android.widget.* and removing this solved the problem. – Saeed Arianmanesh Mar 14 '19 at 11:34
For me the reason was that the class I tried to create did not have an explicit public keyword, which made the class private by default, so it didn't show up in the import context menu of android studio.

- 2,774
- 1
- 25
- 46
For me, the problem was that Gradle targetSdkVersion 30 and compileSdkVersion 30. I changed that at targetSdkVersion 31 and compileSdkVersion 31. And works again. I have tried two days to resolve this issue. And voilà!

- 191
- 1
- 5
For me, the problem was missing lines in to build.gradle (app)
plugins {
id 'kotlin-android-extensions'
}

- 11
- 2
For me the problem was that Power Save Mode was on for some weird reason.
Solution:
Disable "Power Save Mode" in Android Studio menu: File->Power Save Mode

- 511
- 8
- 7
I have same problem here, in my case I think it happen because i forced renaming my flutter projects. And unfortunetly when i realize, i forgot the actual name before i renaming.
But it solve by push to git, then download again the project, reopen with android studio. Voila, it solve. It may stupid way to solve, but it work.
I think it happen because Android studio generated file in project to save setting for each project. But after i rename my folder, the connection between apps and setting file is broken.

- 323
- 2
- 7