Force close after first run

梦想与她 提交于 2019-12-12 05:38:52

问题


I made a project related on the base of telephon system. It works fine in any Samsung android set,HTC and Motorola. But the problem is when i tried to run it in Sony Ericsson Android set it's getting force close in every even time i open the application.

(1st time i open the application it works fine,2nd time open,getting force close....3rd time open, 4th time force close... repeated....)

This is my logcat

08-29 16:53:03.346: E/AndroidRuntime(5812): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.excel.extel/com.excel.extel.ExtelMain}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.excel.extel/com.excel.extel.DialerTab}: android.view.InflateException: Binary XML file line #83: Error inflating class <unknown>
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.ActivityThread.access$1500(ActivityThread.java:121)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.os.Looper.loop(Looper.java:123)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.ActivityThread.main(ActivityThread.java:3701)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at java.lang.reflect.Method.invokeNative(Native Method)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at java.lang.reflect.Method.invoke(Method.java:507)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at dalvik.system.NativeStart.main(Native Method)
08-29 16:53:03.346: E/AndroidRuntime(5812): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.excel.extel/com.excel.extel.DialerTab}: android.view.InflateException: Binary XML file line #83: Error inflating class <unknown>
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.ActivityThread.startActivityNow(ActivityThread.java:1499)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:676)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.widget.TabHost.setCurrentTab(TabHost.java:348)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.widget.TabHost.addTab(TabHost.java:238)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at com.excel.extel.ExtelMain.onCreate(ExtelMain.java:67)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
08-29 16:53:03.346: E/AndroidRuntime(5812):  ... 11 more
08-29 16:53:03.346: E/AndroidRuntime(5812): Caused by: android.view.InflateException: Binary XML file line #83: Error inflating class <unknown>
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.Activity.setContentView(Activity.java:1657)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at com.excel.extel.DialerTab.onCreate(DialerTab.java:139)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
08-29 16:53:03.346: E/AndroidRuntime(5812):  ... 20 more
08-29 16:53:03.346: E/AndroidRuntime(5812): Caused by: java.lang.reflect.InvocationTargetException
08-29 16:53:03.346: E/AndroidRuntime(5812):  at java.lang.reflect.Constructor.constructNative(Native Method)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
08-29 16:53:03.346: E/AndroidRuntime(5812):  ... 32 more
08-29 16:53:03.346: E/AndroidRuntime(5812): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:715)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.content.res.Resources.loadDrawable(Resources.java:1713)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.view.View.<init>(View.java:1969)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.widget.ImageView.<init>(ImageView.java:116)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.widget.ImageButton.<init>(ImageButton.java:85)
08-29 16:53:03.346: E/AndroidRuntime(5812):  at android.widget.ImageBu

Anybody tell me whats the problem?Is it my fault or the set's problem?


回答1:


Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

This means that the device has gone out of memory and it is being force closed.

Now, since you say that the application is running for the first time but not henceforth, I believe that you are not freeing the resources. Bitmaps can sometime take up a lot of space and if you are persisting them in the memory, I would not be surprised if the device goes OOM. Different devices have different specs for memory and that is the reason it is running on some but not on others.

So, my suggestion would be to clear the Bitmaps and the other storage that you are using for temporary purposes.

If that still does not solve your problem, post the code where you are handling the images and we will try to see if there is a more memory efficient way of what you are doing.

Good luck!



来源:https://stackoverflow.com/questions/12176180/force-close-after-first-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!