Reputation: 43
I am working on android 2.2 froyo application. when i am run my apps android 2.2,3.0 that time perfect run. but when i am run on android 4.0 and up that time i give an error.Like unfortunately, apps has stopped.Please help me how can i solve error.
08-03 16:19:36.602: E/AndroidRuntime(581): FATAL EXCEPTION: main
08-03 16:19:36.602: E/AndroidRuntime(581): java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Parcel.readException(Parcel.java:1331)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Parcel.readException(Parcel.java:1281)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.IWindowSession$Stub$Proxy.relayout(IWindowSession.java:634)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.ViewRootImpl.relayoutWindow(ViewRootImpl.java:3586)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1185)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Looper.loop(Looper.java:137)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-03 16:19:36.602: E/AndroidRuntime(581): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 16:19:36.602: E/AndroidRuntime(581): at java.lang.reflect.Method.invoke(Method.java:511)
08-03 16:19:36.602: E/AndroidRuntime(581): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-03 16:19:36.602: E/AndroidRuntime(581): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-03 16:19:36.602: E/AndroidRuntime(581): at dalvik.system.NativeStart.main(Native Method)
Logcat
Error is like:
unfortunately app has stopped
Upvotes: 3
Views: 3425
Reputation: 14367
Check if you have this code in your activities/activity
@Override
public void onAttachedToWindow()
{
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
This was a security hole in earlier versions of Android that could be used to lock the user into the app and prevent him from using the Home button. This is fixed on Android 4 and above and using this will give you the error you see.
Upvotes: 6
Reputation: 16
I could have commented above but i don't have enough reputation.
Maybe your application is not compatible with the API level of 15. Some time ago I did something like that but when I tried to customize the title bar. With constant improvements and enhancements by Google in the new frameworks, breaking the API level is easy. The solution to your problem would be to add a compatibility pack that is available on the website of Android developers. But also we needed to know what is really your problem for you to indicate whether there is a compatibility pack for your problem. Post your code and maybe we can help you efficiently.
Upvotes: 0
Reputation: 13511
Without any sample code it'll be very hard for us to tell where the problem is coming from. However, since you mentioned versioning...
1: In your AndroidManifest.xml file, make sure that your minimum SDK is set to level 8 (Froyo) and the target to 15 (ICS), or better yet, 16 (Jelly Bean). Something like this:
<manifest ...>
...
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application>
...
</application>
</manifest>
2: If you're using Eclipse, right click on your project --> Properties --> Android --> Project Build Target. What API level is checked? Ideally this should be the latest version of Android, which is Jelly Bean, but for your case, Android 4.0.3 will do. If you don't have the SDK for that API level installed in your system, I'm not so sure you can compile against it. Make sure you have installed the API level you are targeting.
Upvotes: 1