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
Changing Text Color of Menu Item in Navigation Drawer
Android Studio: Application Installation Failed
Android Simplecursoradapter Doesn't Update When Database Changes
How to Animate Marker in Android Map API V2
How to Do Circular Scrolling on Viewpager
Immersive Mode Navigation Becomes Sticky After Volume Press or Minimise-Restore
Alternatives to Preferencefragment with Android-Support-V4
How to Test If a Fragment View Is Visible to the User
Update Text of Notification, Not Entire Notification
Cordova Android Requirements Failed: "Could Not Find an Installed Version of Gradle"
Android: How to Get a List of All Available Intent Filters
Exif Orientation Tag Value Always 0 for Image Taken with Portrait Camera App Android
Android: Simulate Wifi in the Emulator