在我的项目中,我注意到模拟器中出现内存不足错误,如下所示
08-03 01:38:28.995: W/dalvikvm(1040): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-03 01:38:29.045: E/AndroidRuntime(1040): FATAL EXCEPTION: main
08-03 01:38:29.045: E/AndroidRuntime(1040): java.lang.RuntimeException: Unable to start activity ComponentInfo{sdei.edustatus/sdei.edustatus.gradebook.GradeBookActivity}: android.view.InflateException: Binary XML file line #78: Error inflating class <unknown>
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.os.Looper.loop(Looper.java:123)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-03 01:38:29.045: E/AndroidRuntime(1040): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 01:38:29.045: E/AndroidRuntime(1040): at java.lang.reflect.Method.invoke(Method.java:507)
08-03 01:38:29.045: E/AndroidRuntime(1040): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-03 01:38:29.045: E/AndroidRuntime(1040): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-03 01:38:29.045: E/AndroidRuntime(1040): at dalvik.system.NativeStart.main(Native Method)
08-03 01:38:29.045: E/AndroidRuntime(1040): Caused by: android.view.InflateException: Binary XML file line #78: Error inflating class <unknown>
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
08-03 01:38:29.045: E/AndroidRuntime(1040): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-03 01:38:29.045: E/AndroidRuntime(1040): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.Activity.setContentView(Activity.java:1657)
08-03 01:38:29.045: E/AndroidRuntime(1040): at sdei.edustatus.gradebook.GradeBookActivity.onCreate(GradeBookActivity.java:311)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-03 01:38:29.045: E/AndroidRuntime(1040): ... 11 more
08-03 01:38:29.045: E/AndroidRuntime(1040): Caused by: java.lang.reflect.InvocationTargetException
08-03 01:38:29.045: E/AndroidRuntime(1040): at java.lang.reflect.Constructor.constructNative(Native Method)
03 01:38:29.045: E/AndroidRuntime(1040): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
08-03 01:38:29.045: E/AndroidRuntime(1040): ... 22 more
08-03 01:38:29.045: E/AndroidRuntime(1040): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.content.res.Resources.loadDrawable(Resources.java:1709)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.View.<init>(View.java:1951)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.View.<init>(View.java:1899)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.view.ViewGroup.<init>(ViewGroup.java:286)
08-03 01:38:29.045: E/AndroidRuntime(1040): at android.widget.RelativeLayout.<init> (RelativeLayout.java:173)
08-03 01:38:29.045: E/AndroidRuntime(1040): ... 25 more
我不认为应该有任何内存泄漏。是的,我正在使用一些图像,我需要单独处理它们吗?????????我的应用程序大小为 2.4mb。
我应该怎么办?