1

可能重复:
java.lang.OutOfMemoryError:位图大小超出 VM 预算

很长时间以来我一直收到此java.lang.OutOfMemoryError: bitmap size exceeds VM budget错误。我在应用程序中使用了许多图像(png)。所有图像的总大小将以 Kb 为单位。我浏览了与该主题相关的各种帖子,但它们与设备有关。我在emulator而不是任何设备上遇到了这个问题,它在我测试过的所有设备上都可以正常工作。可以为这个问题做些什么。

11-08 12:18:53.259: E/AndroidRuntime(1626): FATAL EXCEPTION: main
11-08 12:18:53.259: E/AndroidRuntime(1626): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.curious.solutions.finalautoistdiary/com.curious.solutions.finalautoistdiary.ServiceAdd}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.os.Looper.loop(Looper.java:130)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Method.invokeNative(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Method.invoke(Method.java:507)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at dalvik.system.NativeStart.main(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:684)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.Activity.setContentView(Activity.java:1657)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.curious.solutions.finalautoistdiary.ServiceAdd.onCreate(ServiceAdd.java:77)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-08 12:18:53.259: E/AndroidRuntime(1626):     ... 11 more
11-08 12:18:53.259: E/AndroidRuntime(1626): Caused by: java.lang.reflect.InvocationTargetException
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Constructor.constructNative(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
11-08 12:18:53.259: E/AndroidRuntime(1626):     ... 23 more
11-08 12:18:53.259: E/AndroidRuntime(1626): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.content.res.Resources.loadDrawable(Resources.java:1709)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.View.<init>(View.java:1951)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.View.<init>(View.java:1899)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.ViewGroup.<init>(ViewGroup.java:286)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
11-08 12:18:53.259: E/AndroidRuntime(1626):     ... 26 more
4

0 回答 0