120

I just started using the new android.support.design library. When using any of the widgets inside the XML editor I stop getting the XML autocomplete suggestions!

For example,

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/header_root"
    android:layout_width="match_parent"
    android:layout_height="200dp">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/primary_dark" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:src="@drawable/ic_action_add"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="56dp"
        app:fabSize="normal"
        app:layout_anchor="@id/header_root"
        app:layout_anchorGravity="bottom|right|end" />

</android.support.design.widget.CoordinatorLayout>

None of the tags will show the autocomplete popup, like when I start typing "android:i" no popup appears, the only suggestion I get is shown in the following picture.

enter image description here

I have tried cleaning my project, restarting the pc, restarting Android Studio.. nothing is working!

7
  • 1
    same here, xml auto complete not working when using custom library
    – Damandeep
    Jun 8, 2015 at 4:36
  • Have you resolved this issue yet?
    – dknchris
    Jun 20, 2015 at 9:14
  • Unfortunately, I have not yet. The support library still doesn't populate.
    – Nick H
    Jun 20, 2015 at 18:38
  • 2
    Related bug report: Issue 61844: Autocomplete stopped working. Please star so that they fix the issue. Sep 11, 2015 at 8:10
  • 1
    @Varun haha at least we can gladly say today's AS is leaps and bounds ahead of the first versions back in the day Jul 7, 2019 at 13:09

38 Answers 38

147

If NONE of the above answers worked, ...

Just navigate to your android studio installation directory, i.e,

yourDrive:/.AndroidStudio3.3/system

and DELETE THE CACHE FOLDER ( first close android studio, if its running ).

Then start Android Studio again. Done.

P.S I am using android studio 4.0

5
  • for me, removing the whole .AndroidStudio3.3 folder did the trick. I think it goofed up during the import process.
    – Angel Koh
    Feb 12, 2019 at 14:41
  • 2
    Works for Android 3.6 as well.
    – Abduhafiz
    Mar 20, 2020 at 6:38
  • 1
    Thank you so much @Santanu Sur, It's working for Android 3.6.2 as well.
    – Rovinsan
    Apr 2, 2020 at 1:21
  • 2
    C:\Users\your_user_name\.AndroidStudio3.6\system May 10, 2020 at 1:27
  • 3
    Where is this for macos?
    – Tom
    Jan 13, 2022 at 19:15
137

I have tried a lot of things (restart Android Studio, PC, Invalidate Caches, Power Saver mode,...).

Finally, deleting the .idea folder and all .iml files from the project, restarting Android Studio, and rebuilding Gradle did the trick. Autocomplete in XML support library is working again.

Checking out files from Version Control or copying all the source files in a new project would do the trick as well.

7
  • 6
    The common answers for questions about this, didn't work for me either. I was starting to think I'd just have to put up with it, until I found your answer. Thanks! Jul 16, 2015 at 1:20
  • 4
    Thanks for the solution. Need to open the project by browsing to the physical folder itself. Project entry on Android Studio startup screen didn't work for me.
    – raevilman
    Sep 7, 2015 at 14:23
  • 1
    This method worked for me, but after a few days of coding it seems to always come back. Anyone know if there is a way to find out how it is becoming corrupted?
    – timothyjc
    Sep 16, 2015 at 9:46
  • Same here... in the latest realease of SDK 23, buildTools and support libraries, I saw in the release log, that they fixed some issues around that, lets hope it fixed... :)
    – Marko
    Sep 16, 2015 at 10:45
  • not working. Please use this solution its working fine stackoverflow.com/a/54007742/4373587 Jun 21, 2019 at 6:41
129

The answer for me was to switch to lower sdk when compiling project, I think this is platform problem. I was using sdk 33.

Change in build.gradle

compileSdk=32

Edit: It seems that it is also fixed in newest Android Studio version

2
38

I got my autocomplete suggestions back by invalidating Caches and restarting.

File -> Invalidate Caches / Restart... -> Select Invalidate and Restart

1
  • It seems that invalidate caches/restart solves all the problems in Android Studio!
    – MMG
    Jul 20, 2020 at 14:21
32

This same problem appeared in version 3.2. . The solution for that is

Close Android Studio
Go to C:\Users\UserName\.android and rename the build-cache folder to build-cache.bak

Go to C:\Users\UserName\.AndroidStudio3.2\system and rename these folders

caches to caches.bak

compiler to compiler.bak

compile-server to compile-server.bak

conversion to conversion.bak

external_build_system to external_build_system.bak

frameworks to frameworks.bak

gradle to gradle.bak

resource_folder_cache to resource_folder_cache.bak

Open the Android Studio and open your project again.
3
  • It actually works. We just need to start indexing for android studio again. Like resetting index
    – P Vartak
    Aug 3, 2019 at 8:58
  • works like a charm!! Thanks, android studio resetting its index Nov 12, 2019 at 9:38
  • worked on android studio 4. invalidating, restarting and deleting caches did not work for me and after a while I faced the problem again. but this worked. tnx.
    – Reza
    Aug 26, 2020 at 18:40
25

If NONE of the above worked ...

Just navigate to your android studio installation directory, i.e,

yourDrive:/.AndroidStudio3.4/system

first close android studio, if its running.

then delete the cache folder in system

Then start Android Studio again. Done.

i am using android studio 3.4

3
  • Really helpful, but first try following options and then try above one. Sep 30, 2019 at 14:57
  • Worked perfectly. It is now even showing resources correctly as suggestions Dec 26, 2019 at 12:22
  • I tried everything but didn't get anything working. This answer appears as the savior.
    – Sudarshan
    Jul 23, 2020 at 16:15
9

I try to downgrade the "Compile SDK Version" from 29 to 28 and it's works good

1
  • Targeting sdk version 28 is not supporting on google play store any more. Even those apps targeting 29 won't be accepted on google play store after 31st August 2021.
    – Saqib
    Dec 23, 2020 at 13:10
9

If u have updated ur compileSdkVersion 33. Decrease it. It works in my case

compileSdkVersion 32
 targetSdkVersion 32
6

If you use compileSdkVersion 33, upgrade your Android Studio to Dolphin. It worked for me.

5

The Santanu Sur answer works for me! But in Windows I found these folders in %USERNAME%/.AndroidStudio3.4 or %USERNAME%/.AndroidStudio3.3

I deleted these two folders and it worked well finally.

1
  • 1
    Worked perfectly but delete only caches folder under [Users > Username > .AndroidStudio3.5 > system]. Dec 12, 2019 at 12:08
3

Deleting Library/Application Support/AndroidStudio* folder and Invalidate Cache after that helped me. All other options didn't work.

3

A few years too late, but I wanted to submit an answer to this that I figured out and worked for me. It was very quick and didnt require a lot of reconfiguration as some of other answers on here had, so I thought I'd add it.

Solution

Comment the gradle dependencies for xml attributes, sync the project, and then un-comment them and sync it again. For me, resyncing these three with and then without the comments was enough to get them to start coming up again.

//implementation 'com.android.support:appcompat-v7:27.1.1'
//implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//implementation 'com.android.support:design:27.1.1'

And don't worry if your build fails after the first step, it should if you already have any of those attributes in your project. Another note, the attributes that I had previously put in (without the autocomplete before the resync) needed to be re-inputted for some reason.

2

I got in a situation where only the EditText tag was broken. I've deleted the .idea folder and all .iml, invalidated the cache and restarted... What actually worked was to erase the tag and type it again. Really Odd.

2
  • why its important to delete .idea folder whats the logic
    – blackHawk
    Mar 4, 2017 at 6:29
  • so, we had to check whether the problem exists in all places or in a single file/ in specific files, then should check the broken layout code
    – Blue_Alien
    Jun 26, 2018 at 5:56
2

I too faced this issue and this was only happening on an imported module class. Tried everything like deleting .idea folder, power saver mode, invalidate cache and restart, etc.

Finally updating compileSdkVersion and buildToolsVersion of the module to match with the app module fixed the issue.

In my case I was using:

  compileSdkVersion 29
  buildToolsVersion '29.0.3'
2

Tried everything like deleting .idea folder, power saver mode, deleting cache folder under user/.android , invalidate cache and restart, etc nothing worked.

Setting compileSdkVersion 31 (latest till date) worked for me.

2

As this just happened to me, working with Android Studio Chipmunk Patch 2. and nothing of the above answers worked so targeting SDK version number 33 causing this error lowering it solved the issue

    defaultConfig {
            targetSdkVersion = 30
            compileSdkVersion = 30 }
2

I tried all, Invalidate Cache, Restart, Clean, and rebuild the project. Downgrading from SDK 33 to 30 also I did after searching. Nothing worked.

In the end, I updated my Android Studio from Chipmunk to Dolphin. Everything is sorted now.

So the final conclusion that worked for me is: Update the Android Studio

1

In my case Code Completion suggestions were not appearing because Gradle dependency was missing in my application's module.

I was using android.support.design.widget.TabLayout in my XML layout, but I have not added Design Support Library compile 'com.android.support:design:25.3.1' Gradle dependency in my application module.

1

If you're having this problem in November 2018 with Android Studio 3.2.1, you should try downgrading it to 3.1.4.

With 3.2.1 i tried every of this answers and didn't work, but after i downgraded to 3.1.4 and did the Invalidate Caches / Restart it worked fine.

1

I tried with Invalid caches/restart option but it didn't work for me. For Android Studio 3> versions check following first:

compileSdkVersion
targetSdkVersion
buildToolsVersion

Set these 3 to the latest version and then try to sync the project and clean, ReBuild once. It will work and show the XML editor autocomplete options.

1
  • 1
    Yes. Work for me with androidx library
    – Thomas V J
    Aug 22, 2019 at 16:41
1

Delete the complete folder ` of the android studio and then restarting it. Solve the problem

driveLocation:/.AndroidStudio3.3

.AndroidStudio3.3 may be different in your case

0
1

One possibility is to check power mode in the android studio. Go to File > Power mode and check it's on or off. If it is on, You also will not get any suggestions. To get suggestions, It must be off.

If it doesn't work for you then you should reset your Android studio which will set the default configuration for you. For that, find out .AndroidStudioBeta or .AndroidStudio folder and delete those and restart the android studio. Generally, you will get this folder into users\[user name]\.AndroidStudio3.3.

Let me know if it helps you then. Happy coding..!

1

In my android studio is dolphin(old version) and I have set compileSdkVersion 33 so this issue come then i compileSdkVersion 32 set. It's working fine. So decrease compileSdkVersion version. enter image description here

0

Solved by deleting '.androidStudioPreview1.X' in my home folder.

0

I too got in a situation where only the EditText tag was broken. The solution was found in Setting > Editor >General > Auto Import where Edit Text was listed as excluded from auto completion. Remove that by select and click Minus sign.

0

File -> Invalidate Caches / Restart... -> Select Invalidate and Restart

and turn of power save mode it does works

0

The best option is to make a zip folder of the project and change its path.(Relocate this project than open it). This will do the needful.

0

Check 5 ways:

  1. Restart Android Studio

  2. File -> Invalidate Caches / Restart... -> Select Invalidate and Restart

  3. File -> turn of power save mode and restart Android Studio

  4. Delete .idea folder. Search for *.iml files and delete all those and use way number 2

0

Change to an older version in build.gradle(Module: app) -Make sure is the one under Gradle Script and it is NOT build.gradle(Project: yourproject). After getting XML autocomplete suggestions change to the current version.

0

My issue was that I tried to autocomplete on an xml layout file inside res/xml. Autocomplete does not work there for layout files. Moving the xml file to res/layout made autocomplete work again.

Not the answer you're looking for? Browse other questions tagged or ask your own question.