When you see this error in your console, you're most certainly using some large bitmaps in your application which are taking up a of memory (especially T-Mobile G1, limited to 16 MB).
The solution to this problem is to create a temp storage and pass it to BitmapFactory before decoding. Take into consideration that this error isn't necessarily triggered when handling bitmaps programmatically, but also when specifying them through xml.
If you do specify the bitmaps through xml, for example a background image for a RelativeLayout, just remove the background declaration from xml, and declare the background programmatically, after properly decoding the bitmap.
So, here's the code:
BitmapFactory.Options options = new BitmapFactory.Options(); options.inTempStorage = new byte[16*1024]; Bitmap bitmapImage = BitmapFactory.decodeResource(getResources(), R.drawable.background, options);
If you want to set this bitmap as background, just create a BitmapDrawable, and set it as background:
BitmapDrawable bitmapImageDrawable = new BitmapDrawable(bitmapImage); RelativeLayout yourRelLayout = (RelativeLayout) findViewById(R.id.YourRelativeLayoutId); yourRelLayout.setBackgroundDrawable(bitmapImageDrawable);
Also, you might want to tile you image when setting it as background, so you'll need to do this before calling setBackgroundDrawable
Don't forget to call bitmapImage.recycle() after usage.