代码之家  ›  专栏  ›  技术社区  ›  android developer

为什么我最近从运行安卓10的三星设备上收到这么多InflateException崩溃?

  •  0
  • android developer  · 技术社区  · 6 年前

    出身背景

    出于某种原因 one of my apps 最近,我在“android.view.InflateException”中遇到了相对较多的崩溃。我认为它是从上一两个版本开始的。

    问题

    根据Play Console和Crashlytics的数据,由于某些原因,崩溃只发生在装有Android 10的三星设备上。

    现在这可能是巧合,因为三星的设备相当受欢迎,但我仍然怀疑它。

    在游戏机上,它没有说太多:

    https://i.imgur.com/ZOi7zeY.png

    在Crashlytics上,它似乎与视图膨胀有关,但没有意义,因为它说它是“错误膨胀类TextView”或“错误膨胀类androidx.appcompat.widget.Toolbar”:

    https://i.imgur.com/z1zsCUo.png

    https://i.imgur.com/SJhiUVj.png

    我试过的

    在网上搜索,很遗憾,我在这里找不到类似的病例。

    我能想到的是,也许是我使用的谷歌SDK上的一些缺陷,三星设备有一些问题,因为他们最近才推出Android 10。由于它只发生在过去的1-2个版本中,所以可能就是这样。

    我实际上使用的是谷歌最新版本的SDK。然而,我甚至不使用那里的花哨东西。例如,在Toolbar one上,我的布局有“CoordinatorLayout”、“AppBarLayout”、“Toolbar”和“FragmentContainerView”(用于首选项)。以下是它的布局:

    <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent" android:layout_height="match_parent"
        tools:context=".activities.activity_settings.SettingsActivity">
    
        <com.google.android.material.appbar.AppBarLayout
            android:fitsSystemWindows="true" android:id="@+id/appBarLayout"
            android:layout_width="match_parent" android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">
    
            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay"
                app:title="@string/settings" />
    
        </com.google.android.material.appbar.AppBarLayout>
    
        <androidx.fragment.app.FragmentContainerView
            android:id="@+id/fragmentContainer" android:layout_width="match_parent" android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
    

    以下是我试图更新的一些依赖项,以减少该漏洞的常见程度:

    • “com。谷歌。安卓材料:材料:1.2.0-alpha03'

    • “安德鲁克斯。constraintlayout:constraintlayout:2.0.0-beta4'

    • “安德鲁克斯。核心:核心ktx:1.2.0-rc01'

    • “安德鲁克斯。片段:片段ktx:1.2.0-rc04'

    • “安德鲁克斯。recyclerview:recyclerview:1.1.0'

    • “dev.chrisbanes:insetter:0.2.0”

    • “dev.chrisbanes:insetter ktx:0.2.0”

    问题

    怎么会这样?是什么引起的?我没有看到任何地方提到过。

    这可能是已知的错误吗?为什么它只适用于装有安卓10的三星设备?我已经在我自己的Pixel 4上用安卓10(以及其他安卓版本的设备)测试了它,效果很好。。。

    0 回复  |  直到 6 年前
        1
  •  1
  •   android developer    6 年前

    似乎这都是因为我使用了一些设备上没有定义的系统颜色:

    res/values-v29/颜色。xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <color name="colorAccent">@*android:color/accent_device_default_light</color>
    </resources>