Android Java Out Of Memory Exception Loading Spritsheets
Solution 1:
first of all in your manifest file add this inside application tag android:largeheap=true
then use universal image loader
or picasso
for getting images. do not worry, this libraries manage your images to not be led to crash. picasso and Universal Image Loader.
Solution 2:
Is the dog barking, sad, happy and playful at the same time? You need to try a different approach of what you are trying to do. You definitely don't need every single sprite in memory if you are not even using them.
Solution 3:
You should try inJustDecodeBounds.This will help you to get the size of the image without for scaling without loading them in memory.
If set to true, the decoder will return null (no bitmap), but the out... fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.
Solution 4:
Have you considered using LibGDX?
It has implementations for SpriteSheets (TextureAtlas) and also a tool for building sprites. This way you don't have to spend time writing your own spritesheet renderer/controller.
LibGDX Tutorial for TextureAtlas and Texture Packing
LibGDX is a framework to build games, the project of a Virtual Pet like yours sounds like a great candidate to be implemented with this.
Post a Comment for "Android Java Out Of Memory Exception Loading Spritsheets"