Android内存不足异常

时间:2015-06-04 06:48:20

标签: android out-of-memory assets bitmapfactory android-bitmap

请帮助我解决这个内存异常,因为我无法解决它,任何帮助将不胜感激,

06-04 12:11:44.119: E/AndroidRuntime(9090): FATAL EXCEPTION: main
06-04 12:11:44.119: E/AndroidRuntime(9090): Process: com.zar.bdr, PID: 9090
06-04 12:11:44.119: E/AndroidRuntime(9090): java.lang.OutOfMemoryError
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:594)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:429)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.content.res.Resources.loadDrawable(Resources.java:2113)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.content.res.Resources.getDrawable(Resources.java:700)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.content.res.Resources.loadDrawable(Resources.java:2095)
06-04 12:11:44.119: E/AndroidRuntime(9090):     at android.content.res.TypedArray.getDrawable(TypedArray.java:602)

1 个答案:

答案 0 :(得分:1)

解决方案1:您可以在活动清单中使用android:largeHeap="true"来请求更大的堆大小,但这不适用于任何预装的Honeycomb设备。

解决方案2:使用像

这样的Image Loader库

Universal Image Loader

这使得加载大型图像文件的所有麻烦,也支持一些额外的功能,如缓存和转换。