I\'m having problems with Android Studio. I recently upgraded my SDK Manager to include;
compile \'com.android.support.constraint:constraint-layout:1.0.0-bet
I had the same issues. For me, the reason is my project "Automatically convert third-party libraries to use AndroidXhas". What to do? simply following two steps:
1st step: Please check your gradle.properties, if you see the following lines, you might have the exact same issues as mine. You can firstly delete them.
android.useAndroidX=true
android.enableJetifier=true
2nd step: in main activity, I changed
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
into
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
Everything works all of sudden!
I had the same issue, the app run correctly in other phones but got this exception with a ZTE device. I fixed it by disabling Instant Run 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
please use ConstraintLayout dependency version '2.0.0-beta5', it has solved my issue.
If You using androidx, you must use
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