【问题标题】:runtime error after migrating to androidX迁移到 androidX 后出现运行时错误
【发布时间】:2020-02-19 14:19:39
【问题描述】:

我只是想构建一个签名的apk,然后我遇到了很多错误,我意识到大多数可以通过迁移到android X来解决,但是在迁移到androidX后我得到了这个运行时错误:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.hamed/com.test.hamed.cups}: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class android.support.design.widget.AppBarLayout

这里提到的第 18 行是:

 <android.support.design.widget.
     android:id="@+id/cupsAppBar"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:theme="@style/AppTheme.AppBarOverlay">

在 Java 中是 onCretae 中的这一行:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cups); // <= this line
        .
        .
        .

我搜索了很多,有人建议添加以下行可以解决问题,但它没有:

    implementation 'com.android.support:design:28.0.0'

有什么问题,我该如何解决? 谢谢

【问题讨论】:

  • android X 不会使用任何支持库,请移除 gradle 中的支持并使用 android x 更新包,它会起作用

标签: android android-studio androidx signed-apk


【解决方案1】:

AppBarLayout 现在的正确用法是com.google.android.material.appbar.AppBarLayout

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-12
    • 2019-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-02
    • 2019-10-19
    相关资源
    最近更新 更多