Auto import not working for Android classes in Android studio
Asked Answered
S

7

30

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.

Suffragan answered 25/6, 2014 at 10:29 Comment(2)
Try option + enter if you are using Android Studio on MacOSXRunofthemine
Only for android.xxxxx.xxxxxx i have to copy -paste import linesSuffragan
S
89

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.

Suffragan answered 25/6, 2014 at 11:2 Comment(6)
bravo! what a weird issue for a "stable" beta ideAperture
Not mine. Just ask me to implement the classLobate
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.Troglodyte
Windows 10, Android Studio 2.3.3 - not helpLynnettelynnworth
thanks so much, i am using android studio 3.0.1 and the auto import still doesnt work as intendedColt
Nice , Worked for meBurier
B
12

For me, the problem was that "Show import popup" was not checked at File > Settings > Editor > General > Auto Import > Java.

Bodycheck answered 24/8, 2015 at 11:8 Comment(1)
thanks for location. my problem was Excluding import android.widget.* and removing this solved the problem.Bunsen
D
0

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.

Diarmid answered 21/11, 2017 at 12:38 Comment(0)
C
0

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à!

Cordey answered 24/9, 2021 at 20:47 Comment(0)
P
0

For me, the problem was missing lines in to build.gradle (app)

plugins {
    id 'kotlin-android-extensions'
}
Planography answered 6/11, 2021 at 5:6 Comment(0)
F
0

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.

Fontes answered 8/11, 2022 at 8:41 Comment(0)
C
-1

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

enter image description here

Casie answered 14/3, 2022 at 23:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.