Error Inflating Class Androidx.Constraintlayout.Constraintlayout After Migration to Androidx

Error inflating class androidx.constraintlayout.ConstraintLayout after migration to androidx

I solve my problem by changing all occurrences of

androidx.constraintlayout.ConstraintLayout

to

androidx.constraintlayout.widget.ConstraintLayout

Gradle files causing unexpected app crash: Error inflating class androidx.constraintlayout.ConstraintLayout

You are using firebase libraries which require androidx migration.

Migrate to androidx library.

Here you can find the mappings from old support library artifacts.

For the support-design use the Material Components library: implementation 'com.google.android.material:material:1.0.0'

Then check the package name of your classes. Your error is:

Error inflating class androidx.constraintlayout.ConstraintLayout
Caused by: java.lang.ClassNotFoundException: androidx.constraintlayout.ConstraintLayout

Replace the xml tag <androidx.constraintlayout.ConstraintLayout> with the right class:

androidx.constraintlayout.widget.ConstraintLayout

Here you can find the class mapping.

Error inflating class android.support.constraint.ConstraintLayout

I figured it out, I had to update the android.support.constraint.ConstraintLayout tags to androidx.constraintlayout.widget.ConstraintLayout in my layout XML.

error inflating ConstraintLayout in android studio

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



Related Topics



Leave a reply



Submit