I am having lots of images as frames in my resources/drawable folder
(let say approx 200). And using this images i want run a animation.
The longest animation is of 80Frames. I am successfully able to run
the animation on click of the buttons for some, but for some of the
animation it is giving me OutOfMemoryError saying that VM can't
provide such memory. It is out of VM Budget. I count the size of all
of the images its about 10MB. The size of each image is 320x480 in
pixels.

I try googling and found that i need to explicitly call the Garbage
Collector using System.gc() method. I have done that but still i am
getting some time error of memory. Can anyone please kindly help me
out in this.

Some code snippet :-

AnimationDrawable mailAnimation =
(AnimationDrawable)this.getApplicationContext().getResources().getDrawable(R.anim.blink);
MediaPlayer player = MediaPlayer.create(this.getApplicationContext(),
R.raw.angry);
    if(mailAnimation.isRunning()) {
    mailAnimation.stop();
    mailAnimation.start();
        if (player.isPlaying()) {
        player.stop();
        player.start();
    }
    else {
        player.start();
    }
}
else {
    mailAnimation.start();
        if (player.isPlaying()) {
        player.stop();
        player.start();
    }
    else {
        player.start();
    }
}


Error Log :-

01-16 22:23:41.594: E/AndroidRuntime(399): FATAL EXCEPTION: main
01-16 22:23:41.594: E/AndroidRuntime(399):
java.lang.IllegalStateException: Could not execute method of the
activity
01-16 22:23:41.594: E/AndroidRuntime(399):  at android.view.View
$1.onClick(View.java:2144)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.view.View.performClick(View.java:2485)
01-16 22:23:41.594: E/AndroidRuntime(399):  at android.view.View
$PerformClick.run(View.java:9080)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.os.Handler.handleCallback(Handler.java:587)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.os.Handler.dispatchMessage(Handler.java:92)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.os.Looper.loop(Looper.java:123)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.app.ActivityThread.main(ActivityThread.java:3683)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
java.lang.reflect.Method.invokeNative(Native Method)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
java.lang.reflect.Method.invoke(Method.java:507)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
dalvik.system.NativeStart.main(Native Method)
01-16 22:23:41.594: E/AndroidRuntime(399): Caused by:
java.lang.reflect.InvocationTargetException
01-16 22:23:41.594: E/AndroidRuntime(399):  at
java.lang.reflect.Method.invokeNative(Native Method)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
java.lang.reflect.Method.invoke(Method.java:507)
01-16 22:23:41.594: E/AndroidRuntime(399):  at android.view.View
$1.onClick(View.java:2139)
01-16 22:23:41.594: E/AndroidRuntime(399):  ... 11 more
01-16 22:23:41.594: E/AndroidRuntime(399): Caused by:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:
336)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:
697)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.content.res.Resources.loadDrawable(Resources.java:1709)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.content.res.Resources.getDrawable(Resources.java:581)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:
267)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:
787)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.content.res.Resources.loadDrawable(Resources.java:1694)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.content.res.Resources.getDrawable(Resources.java:581)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
android.view.View.setBackgroundResource(View.java:7533)
01-16 22:23:41.594: E/AndroidRuntime(399):  at
talking.cat.CatActivity.middleButtonClicked(CatActivity.java:83)


If anyone having any idea please kindly let me know any suggestion or
solution for the same. I really need to resolve this.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to