After migrating to AndroidX, Error inflating class

After using Android Studio to migrate my project to AndroidX (and manually fixing a lot of import errors), I'm getting no compile errors but when the app starts I get a crash with:

Error inflating class

The offending line in the layout file is: <

My dependencies in build.gradle are:

dependencies {
    def lifecycle_version = '2.1.0-alpha02'
    // used below--will be different for androidx (migrated 2019-02-04)
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'

    implementation ''
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
    implementation 'com.squareup.okhttp3:okhttp:3.11.0'
    implementation 'com.squareup.okio:okio:1.15.0'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
    implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
    // Relay class
    implementation 'com.jakewharton.rx2:replaying-share:2.1.0'
    // ReplayingShare
    implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
    // RxBinding
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"  // see def above
    // includes ViewModel and LiveData
    implementation 'org.apache.commons:commons-lang3:3.8.1'
    // for tuples like Triple
    implementation 'com.androidplot:androidplot-core:1.5.6'
    // AndroidPlot

I'm guessing that I'm missing something but I can't find what it is.

You need to use

Version 1.0.0 is already out So you can use implementation 'androidx.appcompat:appcompat:1.0.0'

Add dependency implementation ''

See Material Component integration for latest release version. And use



For other artifact and Class Mapping see the AndroidX migration Doc.

I just made a migration to Androidx but after the migration, I'm getting the following error: Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error

Please go through this old to new class mappings

eg;- Use instead of

For AppBarLayout

For Toolbar

Recently when we migrated one of our android application to AndroidX, using android studio’s option from “Refactor -> Migrate to AndroidX” , it was expected that everything should work fine but during compilation it failed with following error,

Androidx inflating class <> will not work it's not exist so replace it with <> it will work fine and don't forgot to add

implementation ''

to your dependencies

Migration Failure. Once your dependency ducks are in a row, the next step is to try Android Studio's "Migrate to AndroidX" tool. Unfortunately, it failed our codebase in multiple ways: The maven coordinates for the AndroidX artifacts were often out-of-date (referring to alpha builds instead of the latest stable builds).

According to the AndroidX migration docs, the androidx replacement for AppBarLayout is Try replacing your AppBarLayout tag with this instead.

As for why compiling/building works, I assume it's something to do with Jetifier, but I'm not certain.

After migrating to Androidx packages using Android Studio menu option Refactor -> Refactor to Androidx my build.gradle looks like implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'

if you are using Kotlin DSL you need to use


and in your layout use <>

AndroidX replaces the original support library APIs with packages in the androidx namespace. Only the package and Maven artifact names changed; class, method, and field names did not change. Note: We recommend working in a separate branch when migrating. Also try to avoid refactoring your code while performing the migration. Prerequisites

The Design Support Library helps you implement shiny, interactive Material Design components and supports phones running extremely old versions of Android!

A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts. While an action bar is traditionally part of an Activity's opaque window decor controlled by the framework, a Toolbar may be placed at any arbitrary level of nesting within a view hierarchy.

implementation 'androidx.constraintlayout:constraintlayout:1.1.3' And replace your xml tag names <androidx.constraintlayout.ConstraintLayout> with <androidx.constraintlayout.widget.ConstraintLayout> in every place where it appears using this shortcut: