android miui ActivityInjector: get life cycle exception java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.app.servertransaction.ClientTransaction

切换主题样式时,抛出的异常(虽然抛出了异常,但功能未受影响,也未崩溃)。
原异常代码:

E/ActivityInjector: get life cycle exception
    java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.app.servertransaction.ClientTransaction
        at android.app.ActivityInjector.checkAccessControl(ActivityInjector.java:24)
        at android.app.Activity.onResume(Activity.java:1859)
        at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java:456)
        at com.afollestad.appthemeengine.ATEActivity.onResume(ATEActivity.java:36)
        at com.***.activities.BaseActivity.onResume(BaseActivity.java:178)
        at com.***.activities.***Activity.onResume(***Activity.java:73)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
        at android.app.Activity.performResume(Activity.java:8050)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4260)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4302)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:57)
        at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:5331)
        at android.app.ActivityThread.access$3500(ActivityThread.java:224)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2054)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7562)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

查到的资料有提到,改变语言也会发生该类异常。且暂时没有解决方案,该异常仅出现在小米型号的手机上。
资料:
ClassCastException on language change

另有资料(MIUI 11/12主题切换结果为LifeCycleException、ClassCastException)提到添加:

<item name="android:forceDarkAllowed">false</item>

方式来解决,未尝试,因该属性需要提高依赖的sdk版本(也有人提到该方法也无法解决)。

posted @ 2022-11-01 23:43  流失的痕迹  阅读(1340)  评论(0编辑  收藏  举报