Out of Memory Error Android ImageViews

时间:2014-10-08 04:21:22

标签: android out-of-memory

好的,所以在我的应用程序中,我有多个ImageView,每个都有一个.png图标。现在有7 ...然而我的应用程序,随机间隔,将崩溃与一个对话框(应用程序无响应),然后它抛出此异常:

10-08 00:14:15.528  32732-32732/com.antechdevelopment.NotificationReminders E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.antechdevelopment.NotificationReminders, PID: 32732
java.lang.OutOfMemoryError
        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:677)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:507)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:872)
        at android.content.res.Resources.loadDrawable(Resources.java:3024)
        at android.content.res.Resources.getDrawable(Resources.java:1586)
        at android.app.ApplicationPackageManager.getDefaultActivityIcon(ApplicationPackageManager.java:783)
        at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3466)
        at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1879)
        at android.view.Window.findViewById(Window.java:924)
        at android.app.Activity.findViewById(Activity.java:1965)
        at android.app.Activity$1.findViewById(Activity.java:745)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:880)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
        at android.app.BackStackRecord.run(BackStackRecord.java:684)
        at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
        at android.app.Activity.performStart(Activity.java:5435)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
        at android.app.ActivityThread.access$900(ActivityThread.java:161)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5356)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
        at dalvik.system.NativeStart.main(Native Method)

有没有人有想法?我很难过和生气!谢谢!

1 个答案:

答案 0 :(得分:6)

正如错误所述,您的内存不足。这很可能是由于图像的大小以及图像的加载方式。已经创建了许多lib来解决这些问题。

尝试使用一些图像加载库,如下所示。最有可能的是,您可以使用其中一个经过测试的库来解决您的问题。