迁移到AndroidX后,错误膨胀了类android.support.design.widget.AppBarLayout [英] After migrating to AndroidX, Error inflating class android.support.design.widget.AppBarLayout

查看:898
本文介绍了迁移到AndroidX后,错误膨胀了类android.support.design.widget.AppBarLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Android Studio将项目迁移到AndroidX(并手动修复了很多导入错误)之后,我没有遇到编译错误,但是当应用启动时,我崩溃了:

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 android.support.design.widget.AppBarLayout.

布局文件中有问题的行是: <android.support.design.widget.AppBarLayout

The offending line in the layout file is: <android.support.design.widget.AppBarLayout

我在build.gradle中的依赖项是:

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 'com.google.android.material:material:1.1.0-alpha03'
    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.

推荐答案

您需要使用com.google.android.material.appbar.AppBarLayout.

版本1.0.0已经发布,因此您可以使用implementation 'androidx.appcompat:appcompat:1.0.0'

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

添加依赖项implementation 'com.google.android.material:material:1.0.0'

有关最新版本,请参见材料组件集成. 并使用

See Material Component integration for latest release version. And use

<com.google.android.material.appbar.AppBarLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

</com.google.android.material.appbar.AppBarLayout>

有关其他工件和类映射,请参见 AndroidX迁移文档.

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

这篇关于迁移到AndroidX后,错误膨胀了类android.support.design.widget.AppBarLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆