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

后端 未结 17 1162
[愿得一人]
[愿得一人] 2020-11-27 14:24

I just made a migration to androidx through Android Studio menu option Refactor -> Refactor to AndroidX

I\'m getting the following

相关标签:
17条回答
  • 2020-11-27 15:00

    change your constraint layout dependancy to implementation 'androidx.constraintlayout:constraintlayout:2.0.2'

    0 讨论(0)
  • 2020-11-27 15:02

    Make Sure you have added the dependency for constraint layout

     dependencies  {
        implementation "androidx.constraintlayout:constraintlayout:1.1.3"
    }
    

    and have made the changes to

    <androidx.constraintlayout.widget.ConstraintLayout instead of
    
    <android.support.constraint.ConstraintLayout
    
    0 讨论(0)
  • 2020-11-27 15:04

    I has same issue after:

    • migration support library to androidx;
    • increment targetSdkVesrsion to 29;

    I also use:

    implementation "uk.co.chrisjenx:calligraphy:2.3.0"
    

    I tried all posts from this question, but none success.

    I fix it by adding one string .disableCustomViewInflation() to Calligraphy init:

    @Override
    public void onCreate() {
    
        super.onCreate();
        // ...
        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                .setDefaultFontPath("fonts/Sans-Regular.ttf")
                .setFontAttrId(R.attr.fontPath)
                .disableCustomViewInflation() // <----- this fix
                .build());
        // ...
    }
    

    I hope next release of Calligraphy (Christopher Jenkins thanks for your great job) will fix it inside too.

    0 讨论(0)
  • 2020-11-27 15:06
    1. Find all default before to click Refactor -> Refactor to AndroidX
    2. Open this https://developer.android.com/jetpack/androidx/migrate/class-mappings and find "android.support.v4.widget.DrawerLayout". In same line AndroidX class name is "androidx.drawerlayout.widget.DrawerLayout" copy it.

    1. Replace all "android.support.v4.widget.DrawerLayout" to "androidx.drawerlayout.widget.DrawerLayout" in your project"s code, layout and menu. After all replace it will work.

    I mean find mapping and use it in whole project.

    0 讨论(0)
  • 2020-11-27 15:07

    I had the same problem, I resolved it as follows:

    In your dependecies if you have added

    implementation 'androidx.constraintlayout:constraintlayout:1.x.x' that is correct

    but in your xml layout file you have to use the widget as

    androidx.constraintlayout.widget.ConstraintLayout

    0 讨论(0)
  • 2020-11-27 15:09

    I solve my problem by changing all occurrences of

    androidx.constraintlayout.ConstraintLayout

    to

    androidx.constraintlayout.widget.ConstraintLayout

    0 讨论(0)
提交回复
热议问题