'Android studio layout editor. Waiting for build to finish

Android studio layout preview is stuck in waiting for build to finish even though there is no build happening. I have invalidate and restarted android studio. I have uninstalled and reinstalled. It is still having the same issue. I noticed this began after I created an xml file with constraintLayout. I have since removed it, but that didn't help.



Solution 1:[1]

I am getting same problem since I added material components. Are you using material components in your project? I am using com.google.android.material:material:1.2.0-alpha04 and since I added either switch or slider, the problems starting happening.. I am still investigating.

UPDATE: Ok, solved the problem for me, so I would look at what components you are using in your layout. For me it was "com.google.android.material.slider.Slider" This completely breaks layout previews in android studio, even when you open a different project.

This is a nasty bug!!!! To get layout preview working again, invalidate caches and restart, but do not go into the "infected" layout, as it will break the whole of Android Studio again.

Solution: If using these components, try and switch to 3rd party library until fix from google. Have raised bug report here: https://github.com/material-components/material-components-android/issues/992

Solution 2:[2]

I don't think so it's problem related to constraint layout Please try following things "File > Sync Project with Gradle files" (worked for me) File > Invalidate Cache & Restart > Just Restart OR File > Invalidate Cache & Restart > Invalidate & Restart Close Project and Re-Import the Project

Solution 3:[3]

Just check if you are using androidX libraryies in your build.gradle and maybe you are using android.support.constraint.ConstraintLayout then replace this with androidx.constraintlayout.widget.ConstraintLayout Or if you are having support libraries in your gradle file then you should also have support library's ConstraintLayout.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 mihir lad
Solution 3 Ryan M