Android Crash, java.lang.IllegalArgumentException: Window type can not be changed after the window is added

Edward Jezisek picture Edward Jezisek · Jun 11, 2013 · Viewed 7.3k times · Source

I uploaded an Android Application to the market, and, for some reason a user is getting this error.

java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
at android.os.Parcel.readException(Parcel.java:1331)
at android.os.Parcel.readException(Parcel.java:1281)
at android.view.IWindowSession$Stub$Proxy.relayout(IWindowSession.java:664)
at android.view.ViewRootImpl.relayoutWindow(ViewRootImpl.java:3594)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1193)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2450)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4444)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)

I am pretty sure I never use WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG as referenced in other postings. I do however, have a window that switches between WindowManager.LayoutParams.TYPE_PHONE and WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY. Which seems like it could be the error. I would prefer not changing this as it would require me to have two windows instead of just one. Thanks in advance!

Answer

Albert.Qing picture Albert.Qing · Oct 11, 2013

check AndroidManifest.xml

<uses-sdk  //************
            android:targetSdkVersion="X"/>

X must be less than 14 Or remove this attribute. good luck guy.