我浏览了几篇文章,注意到有时在应用程序退出时不会调用 onDestroy() 。有时只调用 onPause()。我的全部事情是,当我使用后退按钮或 finish() 函数退出我的应用程序时,一切看起来都很好。当我尝试重新打开我的应用程序时,它说:
12-14 04:09:59.457: E/GraphicsJNI(996): VM won't let us allocate 3279360 bytes
我也会粘贴整个日志。问题是当它重新打开时,它会强制关闭。之后,我可以重新打开它。例如,每当我在 Eclipse 中重建它并通过模拟器运行它时,它都能正常工作。但是如果我在应用程序中关闭它并尝试重新打开它,那就是我遇到这个内存问题的时候。我不确定什么没有被清除,我真的希望你们中的一个人有一个解决方案,或者至少可以为我指出正确的方向来解决这个问题,因为这真的让我头疼。如果你们需要更多信息,请告诉我。谢谢。
12-14 04:09:59.457: E/GraphicsJNI(996): VM won't let us allocate 3279360 bytes
12-14 04:09:59.606: D/AndroidRuntime(996): Shutting down VM
12-14 04:09:59.646: W/dalvikvm(996): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-14 04:09:59.856: E/AndroidRuntime(996): FATAL EXCEPTION: main
12-14 04:09:59.856: E/AndroidRuntime(996): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ShotSlot/com.ShotSlot.ShotSlotActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.os.Handler.dispatchMessage(Handler.java:99)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.os.Looper.loop(Looper.java:123)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-14 04:09:59.856: E/AndroidRuntime(996): at java.lang.reflect.Method.invokeNative(Native Method)
12-14 04:09:59.856: E/AndroidRuntime(996): at java.lang.reflect.Method.invoke(Method.java:521)
12-14 04:09:59.856: E/AndroidRuntime(996): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-14 04:09:59.856: E/AndroidRuntime(996): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-14 04:09:59.856: E/AndroidRuntime(996): at dalvik.system.NativeStart.main(Native Method)
12-14 04:09:59.856: E/AndroidRuntime(996): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
12-14 04:09:59.856: E/AndroidRuntime(996): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-14 04:09:59.856: E/AndroidRuntime(996): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.Activity.setContentView(Activity.java:1647)
12-14 04:09:59.856: E/AndroidRuntime(996): at com.ShotSlot.ShotSlotActivity.onCreate(ShotSlotActivity.java:161)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-14 04:09:59.856: E/AndroidRuntime(996): ... 11 more
12-14 04:09:59.856: E/AndroidRuntime(996): Caused by: java.lang.reflect.InvocationTargetException
12-14 04:09:59.856: E/AndroidRuntime(996): at android.widget.RelativeLayout.<init>(RelativeLayout.java:170)
12-14 04:09:59.856: E/AndroidRuntime(996): at java.lang.reflect.Constructor.constructNative(Native Method)
12-14 04:09:59.856: E/AndroidRuntime(996): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
12-14 04:09:59.856: E/AndroidRuntime(996): ... 21 more
12-14 04:09:59.856: E/AndroidRuntime(996): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.Bitmap.nativeCreate(Native Method)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.content.res.Resources.loadDrawable(Resources.java:1709)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.View.<init>(View.java:1885)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.View.<init>(View.java:1834)
12-14 04:09:59.856: E/AndroidRuntime(996): at android.view.ViewGroup.<init>(ViewGroup.java:285)
12-14 04:09:59.856: E/AndroidRuntime(996): ... 25 more