Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓10崩溃(布局/abc#U屏幕#U简单线#17中的充气异常)_Android_Androidx_Android 10.0_Calligraphy - Fatal编程技术网

Android 安卓10崩溃(布局/abc#U屏幕#U简单线#17中的充气异常)

Android 安卓10崩溃(布局/abc#U屏幕#U简单线#17中的充气异常),android,androidx,android-10.0,calligraphy,Android,Androidx,Android 10.0,Calligraphy,从安卓4.3到安卓9,我的应用程序运行良好,但我的应用程序无法在安卓10(QAPI 29)上运行,因此崩溃。这是我的日志-为什么会发生这种情况 java.lang.RuntimeException: Unable to start activity ComponentInfo{ir.mahdi.circulars/ir.mahdi.circulars.MainActivity}: android.view.InflateException: Binary XML file

从安卓4.3到安卓9,我的应用程序运行良好,但我的应用程序无法在安卓10(QAPI 29)上运行,因此崩溃。这是我的日志-为什么会发生这种情况

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>

您可以将buildTools版本和sdk版本从29更改为28

    targetSdk = 28
    compileSdk = 28
    buildTools = '28.0.3'

当然,你的问题是书法图书馆,我也有同样的问题,有两种解决方法:

  • 返回到目标版本28,并等待可能的更新 书法图书馆。二,
  • 删除库
  • 关于异常:

    书法中的例外错误来自于在图书馆中使用反射。请参阅此异常的最后一行:

    E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example, PID: 8220
    android.view.InflateException: Binary XML file line #17 in com.example:layout/abc_screen_simple: Binary XML file line #17 in com.example/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
    Caused by: android.view.InflateException: Binary XML file line #17 in com.example/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
    
    Android在您的文档中解释了一些反射方法(非SDK接口)在API 29平台中受到限制

    通过Class.getDeclaredField()或Class.getField()----------->NoSuchFieldException引发的反射

    通过Class.getDeclaredMethod()、Class.getMethod()--->NoSuchMethodException引发的反射

    通过Class.getDeclaredFields()、Class.getFields()----------->非SDK成员进行的反射不在结果中

    通过Class.getDeclaredMethods()、Class.getMethods()->非SDK成员的反射不在结果中


    书法
    更新为最新版本以解决此问题: 链接:

    更具体地说,视图泵都需要更新:

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

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

    当遇到此问题时,只需将应用程序gradle中的书法和可视泵更新至最新版本即可。目前的版本是: 实现“io.github.inflationx:calligraphy3:3.1.1”
    实现“io.github.inflationx:viewpump:2.0.3”

    如果您正在使用书法,则应迁移到书法3:

    迁离 到
    并将
    书法
    更新为最新版本

    您需要更新书法版本并根据新版本更改代码

    Please foloow this below steps.
    1> First of all check build.gradle(:app) file
    2> If you are using  this below library:
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    3> Update this " implementation 'uk.co.chrisjenx:calligraphy:2.3.0' " library with this below library.
    implementation 'io.github.inflationx:viewpump:2.0.3'
    implementation 'io.github.inflationx:calligraphy3:3.1.1'
    4> In project where You use this below code :
    @Override
        protected void attachBaseContext(Context newBase) {
            super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
        }
    
    5> Update it with this below code:
    
       @Override
        protected void attachBaseContext(Context newBase) {
            super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
        }
    
    您需要从更改依赖项中的存储库

    implementation "uk.co.chrisjenx:calligraphy:$caligraphyVersion"
    

    您需要从更改导入的用法

    import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
    

    书法配置来自

    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                   .setDefaultFontPath(getResources().getString(R.string.bariol))
                   .setFontAttrId(R.attr.fontPath)
                    .build())) 
                    .build());
    

    我用的是bariol字体,你可以把它改成你的

    &新基地

    super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
    

    build.gradle(:app)文件中使用下面的更新您的书法导入

    实现“io.github.inflationx:viewpump:2.0.3”

    实现“io.github.inflationx:calligraphy3:3.1.1”


    并使用ViewPumpContextWrapper而不是CalligraphyContextWrapper

    此依赖项
    实现'com.ice.restring:restring:1.0.0'
    如果targetSdkVersion等于29,也会导致此崩溃



    因此,如果您有这种依赖关系(
    implementation'com.ice.restring:restring:1.0.0'
    )在你的gradle中,你可以通过删除它或使用另一个与
    targetSdkVersion 29

    一起工作的库来解决这个问题。使用这个库com.google.android.material:material:1.0.0-rc01代替com.google.android.material:material:1.0。0@MilanPansuriya不工作请共享您的整个错误日志。。。通常,在这些情况下,真正的原因是在崩溃结束时提到的trace@W0rmH0le我发现了这个问题,它来自书法图书馆,所以我通过删除它来修复它it@git,是否以任何其他方式而不是删除
    书法
    ?我找不到解决这个问题的方法,但是我发现这个库可以方便地使用字体,知道吗?这是正确的答案。实现'io.github.inflationx:calligraphy3:3.1.1'实现'io.github.inflationx:viewpump:2.0.3'@KonstantinKuznetsov是正确的。我们案例中的问题是:书法库在2.2.0和3.1.1之间发生了相当大的变化,更新应用程序代码非常重要。例如,
    CalligraphyContextWrapper
    在3.1.1.Update中不再存在:实际上,更新到3.1.1.Update非常简单;中的代码片段使其变得简单明了。但问题是,至少在我们的案例中,书法更新没有起到任何作用:在那之后,仍然会对
    layout/abc\u screen\u simple
    产生膨胀的异常。@Jonik hmm。。很奇怪。也许你的应用程序中的一些独立模块仍然对书法有旧的依赖关系?您是否尝试检查gradle中的可传递依赖项,也许您会看到一些奇怪的情况?我冒昧地将缺少的信息编辑到了答案中。这是一个解决方法,但在某种情况下,您可能希望将
    targetSdk
    更新为29,并且您需要正确处理该问题。只有targetSdk必须是28,compileSdk和buildTools可以是29,但这是暂时解决方案。很可能,项目中添加了书法依赖项是有原因的。不需要移除它;更新到书法3也修复了膨胀异常的问题:这个解决方案被正确地解释了,它解决了这个问题。这是完整和充分的解释!答案不会比这更好,谢谢!!谢谢你,伙计,它很有魅力
    import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
    
    import io.github.inflationx.calligraphy3.CalligraphyConfig;
    
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                   .setDefaultFontPath(getResources().getString(R.string.bariol))
                   .setFontAttrId(R.attr.fontPath)
                    .build())) 
                    .build());
    
    ViewPump.init(ViewPump.builder()
                .addInterceptor(new CalligraphyInterceptor(
                        new CalligraphyConfig.Builder()
                                
                .setDefaultFontPath(getResources().getString(R.string.bariol))
                                .setFontAttrId(R.attr.fontPath)
                                .build()))
                .build());
    
    super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));