Android Studio - XML Editor autocomplete not working with support libraries

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.

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

Answers


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

Finally, deleting .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.


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

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


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 3.3


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.


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.

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


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.


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.


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


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.


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

and turn of power save mode it does works


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.


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.


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


What worked for me was renaming $USERDIR/.AndroidStudio3.3/system folder and restarting AS.


Need Your Help

WooCommerce return product object by id

php wordpress woocommerce

I am creating a custom theme for woocommerce and I need to be able to create a mini product display. I am having problems finding documentation on the woocommerce api. I have a comma delimited list...

What's the difference between a header file and a library?

c++ c

One of the things I'm having a hard time understanding is how the compiler works. I'm having a lot of difficulties with it, but in particular I keep getting headers and libraries mixed up. If someb...