解决system_server crash,java.lang.IllegalStateException: has already been added to the window manager.

Posted 小B伏枥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决system_server crash,java.lang.IllegalStateException: has already been added to the window manager.相关的知识,希望对你有一定的参考价值。

日志描述:

Process: system_server
Build: android/aosp_coral_car/coral:10/QQ3A.200705.002/eng.bill.20210413.091937:userdebug/test-keys

java.lang.IllegalStateException: View android.widget.LinearLayout{72fec73 VFE...C.. ......I. 0,0-0,0 #1020353 android:id/ndmode_ll} has already been added to the window manager.
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:359)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
    at com.android.internal.widget.NDModeView.addView(NDModeView.java:109)
    at com.android.server.wm.DisplayPolicy.enableNDMode(DisplayPolicy.java:3760)
    at com.android.server.wm.DisplayPolicy.access$800(DisplayPolicy.java:187)
    at com.android.server.wm.DisplayPolicy$PolicyHandler.handleMessage(DisplayPolicy.java:436)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.os.HandlerThread.run(HandlerThread.java:67)
    at com.android.server.ServiceThread.run(ServiceThread.java:44)
    at com.android.server.UiThread.run(UiThread.java:43)

 

解决方案:

    public void addView() {
        debug(DEBUG, "Function, addView(), has been executed.1");
        if(mXXXView.getParent() != null){
            mWindowManager.removeViewImmediate(mXXXView);
        }
        mWindowManager.addView(mXXXView, mLayoutParams);
    }

以上是关于解决system_server crash,java.lang.IllegalStateException: has already been added to the window manager.的主要内容,如果未能解决你的问题,请参考以下文章

Android 12 进程native crash流程分析

Android logcat使用总结

关于VSCode出现the window has crashed的一种解决办法

关于VSCode出现the window has crashed的一种解决办法

frida hook android system_server 报告错误:期望一个指针

iOS中常见的 Crash 场景以及解决方法