I am developing an Android Application to load some images to emulator, but it fails with the below error:
11-07 19:38:51.596: E/dalvikvm-heap(322): 73670400-byte external
allocation too large for this process.
11-07 19:38:51.596: E/GraphicsJNI(322): VM won't let us allocate
73670400 bytes
11-07 19:38:51.596: D/AndroidRuntime(322): Shutting down VM
11-07 19:38:51.616: W/dalvikvm(322): threadid=1: thread exiting with
uncaught exception (group=0x4001d800)
11-07 19:38:51.926: E/AndroidRuntime(322): FATAL EXCEPTION: main
11-07 19:38:51.926: E/AndroidRuntime(322): java.lang.OutOfMemoryError:
bitmap size exceeds VM budget
11-07 19:38:51.926: E/AndroidRuntime(322): at
android.graphics.Bitmap.nativeCreate(Native Method)
11-07 19:38:51.926: E/AndroidRuntime(322): at
android.graphics.Bitmap.createBitmap(Bitmap.java:468)
11-07 19:38:51.926: E/AndroidRuntime(322): at
android.graphics.Bitmap.createBitmap(Bitmap.java:435)
My Java code is below in which the error is occurring. I used System.out.println
to debug the issue.
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
System.out.println("11");
ImageView imageView = new ImageView(context);
System.out.println("12");
imageView.setImageResource(imageIDs[position]);
System.out.println("13");
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
System.out.println("14");
imageView.setLayoutParams(new Gallery.LayoutParams(150, 220));
System.out.println("15");
imageView.setBackgroundResource(itemBackGround);
System.out.println("16");
return imageView;
}
If you can help, I would really appreciate that. Thanks.