在屏幕上设置动态壁纸时出现OutOfMemoryError

时间:2013-02-15 09:22:16

标签: android out-of-memory live-wallpaper

02-15 09:10:02.196: E/dalvikvm-heap(881): Out of memory on a 2162176-byte allocation.
02-15 09:10:02.376: E/AndroidRuntime(881): FATAL EXCEPTION: main
02-15 09:10:02.376: E/AndroidRuntime(881): java.lang.OutOfMemoryError
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:378)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.plugai.android.livewallpapers.fishes.ClownFish.<init>(ClownFish.java:20)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.plugai.android.livewallpapers.Aquarium.addFishes(Aquarium.java:88)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.plugai.android.livewallpapers.Aquarium.initialize(Aquarium.java:81)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.plugai.android.livewallpapers.AquariumWallpaperService$AquariumWallpaperEngine.<init>(AquariumWallpaperService.java:20)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.plugai.android.livewallpapers.AquariumWallpaperService.onCreateEngine(AquariumWallpaperService.java:10)
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:1034)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:40)
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.os.Looper.loop(Looper.java:137)
02-15 09:10:02.376: E/AndroidRuntime(881):  at android.app.ActivityThread.main(ActivityThread.java:5039)
02-15 09:10:02.376: E/AndroidRuntime(881):  at java.lang.reflect.Method.invokeNative(Native Method)
02-15 09:10:02.376: E/AndroidRuntime(881):  at java.lang.reflect.Method.invoke(Method.java:511)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-15 09:10:02.376: E/AndroidRuntime(881):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-15 09:10:02.376: E/AndroidRuntime(881):  at dalvik.system.NativeStart.main(Native Method)

2 个答案:

答案 0 :(得分:3)

显然,动态壁纸需要比你更多的内存(RAM)。

答案 1 :(得分:2)

您收到OutOfMemory异常。这意味着您的应用尝试在设备RAM中分配太多内存。这通常是由于尝试加载大于所需的图像而造成的。

尝试缩小您在动态壁纸中使用的任何图形。