将项目更新到android 10后onCreate活动崩溃 [英] Crash in onCreate activity after update project to android 10

查看:143
本文介绍了将项目更新到android 10后onCreate活动崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将项目更新为android 10之后,我在HomeActivity上崩溃了,该应用程序在较旧版本的android上运行正常,但是当我使用Android 10设备时崩溃了,我进行了启动活动,并且运行正常,但是崩溃发生了在onCreate setContentView(R.layout.activity_home);

After updating my project to android 10 I got crash on my HomeActivity , the app works fine on older versions of android but the crash happens when I use Android 10 device , I have a splash activity and it works fine but the crash happens after moving to the home activity on onCreate setContentView(R.layout.activity_home);

这是崩溃报告:

  E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aia.portercustomer/com.aia.portercustomer.activity.HomeActivity}: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3271)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7397)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
     Caused by: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
     Caused by: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/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
        at uk.co.chrisjenx.calligraphy.ReflectionUtils.getValue(ReflectionUtils.java:29)
        at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:203)
        at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20)
        at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302)
        at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:239)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
        at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:631)
        at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:466)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.aia.portercustomer.activity.HomeActivity.onCreate(HomeActivity.java:408)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1300)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3246)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2020-03-03 11:26:24.019 17491-17491/com.aia.portercustomer E/UncaughtException:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7397)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

我还尝试了此答案中的解决方法 Android 10 Activity onCreate Crash 将这些依赖项添加到我的项目中

Also I tried the solutuin mention in this answer Android 10 Activity onCreate Crash by adding these dependencies to my project

    // Annotation processor
    annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.2.0-alpha05"
    // alternately - if using Java8, use the following instead of lifecycle-compiler
    implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0-alpha05"
    implementation "androidx.lifecycle:lifecycle-runtime:2.2.0-alpha05"
    implementation "androidx.lifecycle:lifecycle-process:2.2.0-alpha05"
    implementation "androidx.lifecycle:lifecycle-service:2.2.0-alpha05"

但是没有帮助.

推荐答案

查看崩溃日志:

 Caused by: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout

在您的 app.gradle 中,添加以下内容:

In your app.gradle, add the following:

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

详细了解此问题

这篇关于将项目更新到android 10后onCreate活动崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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