android - 在 Android 10 上崩溃(布局/abc_screen_simple 行 #17 中的 InflateException)

标签 android androidx android-10.0 calligraphy

我的应用程序从 Android 4.3 到 Android 9 Pie 都可以正常运行,但我的应用程序无法在 Android 10 (Q API 29) 上运行并崩溃。这是我的 logcat - 为什么会这样?

java.lang.RuntimeException: Unable to start activity 
     ComponentInfo{ir.mahdi.circulars/ir.mahdi.circulars.MainActivity}: 
     android.view.InflateException: Binary XML file line #17 
     in ir.mahdi.circulars:layout/abc_screen_simple: Binary XML file line #17 
     in ir.mahdi.circulars:layout/abc_screen_simple: 
         Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout

这是我的 mainActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:background="@color/white"
    android:layoutDirection="ltr"
    tools:context=".MainActivity">


</androidx.coordinatorlayout.widget.CoordinatorLayout>

更新

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 29
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    } }

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' }

最佳答案

更新 Calligraphy 到最新版本来解决这个问题: 链接:https://github.com/InflationX/Calligraphy/issues/35

更具体地说,Calligraphy ViewPump 都需要更新:

implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'

从 Calligraphy 2 迁移到 3 需要更改一些代码;请参阅 Calligraphy 3 README 中的示例.

关于android - 在 Android 10 上崩溃(布局/abc_screen_simple 行 #17 中的 InflateException),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56524914/

相关文章:

android - 如何在我的 Android 应用程序中实现这样的布局?

Android RecyclerView 缺少项目的大差距

android - play-services-ads与appcompat发生冲突

android - 如何使用带有自定义入口点的 FlutterFragment 在我的 Android 应用程序中嵌入 Flutter 布局?

android - 升级androidx时资源 'attr/visibility'的值重复

java - 想列出内部存储和外部存储上的所有音乐文件,但在 Android 10 上无法完成

java - facebook android sdk shareddialog回调总是成功的

c# - android xamarin 中的动态

java - 如何在 Android 10 中打开 Activity (传入 voip 调用)

android - 检查互联网是否可用(targetSdk : Android Q)