error inflating ConstraintLayout in android studio

I don't know if this was solution 2 and half years ago, but today i had similar error. Found the answer right here: Error inflating class androidx.constraintlayout.ConstraintLayout after migration to androidx

Basically only xml tags of constraint layout should be renamed to these ->

androidx.constraintlayout.widget.ConstraintLayout


You should add as below

<android.support.constraint.ConstraintLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/PLAY_PARENT"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@drawable/greenfelt2"
 android:padding="0dp">

compile 'com.android.support.constraint:constraint-layout:1.0.2'

For the latest release check here

check out this project for more on ConstraintLayout Usage

Update

For those who are switching from android support to androidx, remember to change android.support.constraint.ConstraintLayout to androidx.constraintlayout.widget.ConstraintLayout


If You using androidx, you must use

androidx.constraintlayout.widget.ConstraintLayout