jeudi 14 février 2019

Resolve Android Error "android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout"

In Android Studio, when creating a default project for Android Lollipop 5.1.1, using AndroidX functionalities, the following error can be shown in the debug output of Android Studio, just after the application crashes :

"android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout"

The solution that I have found is to change the versions of dependencies to the newer ones in the build.gradle file for the Module: app such as :

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0-alpha02' implementation 'androidx.core:core-ktx:1.1.0-alpha04' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.2-alpha01' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'}