0

I'm having some trouble with frame animation: I have an app with an ImageView on which I would like to show some frame-by-frame animation. My code is as follows: Main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/spotim000" />

</LinearLayout>

and my java is:

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class AnimationTestActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageView imageView1 = (ImageView) findViewById(R.id.imageView1);
    imageView1.setImageResource(R.drawable.spotlights);
}
}

spotlights.xml:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/spotim000" android:duration="50" />
<item android:drawable="@drawable/spotim001" android:duration="50" />
<item android:drawable="@drawable/spotim002" android:duration="50" />
...
<item android:drawable="@drawable/spotim099" android:duration="50" />
<item android:drawable="@drawable/spotim100" android:duration="50" />

</animation-list>

I didn't include the code that starts the animation - because the problem isn't there. When I launch this code using the emulator or using my HTC Desire - the code runs prefectly. However, when I run it on a Samsung Galaxy S2 - I get this error:"java.lang.outofmemoryerror bitmap size exceeds vm budget on bitmap"

When I remove some of the frames (leaving lets say 20 out of the original 101) it works fine also on the galaxy. But I need all the frames and I can't really get why it works on a HTC Desire but not on the much stronger Galaxy S2

I've been looking on other posts with similar problem but the only one I could find is this un-answered post: Android Animation (XML) Giving OutOfMemoryError: bitmap size exceeds VM budget (only on Motorola Droids?)

Anyone has any insights on this matter?

Thanks a lot, Shai :)

Community
  • 1
  • 1
shaylh
  • 1,841
  • 3
  • 17
  • 19
  • 1
    Welcome to hell xD You could try to reduce the size of the images... – Sebastián Castro Feb 03 '12 at 19:26
  • http://stackoverflow.com/questions/3324010/android-outofmemoryerror-bitmap-size-exceeds-vm-budget – Yellos Feb 03 '12 at 19:29
  • Yellos - Thanks for the reff. I've already seen this post but it doesn't help me because I'm not leaking any memory - This happens when starting the app, in the first activity! The app doesn't even get a chance to load and leak anything O.o – shaylh Feb 03 '12 at 19:33
  • 1
    See http://stackoverflow.com/questions/8692328/causing-outofmemoryerror-in-frame-by-frame-animation-in-android for similar question and possible solution. – Asaf Pinhassi Jun 12 '12 at 09:37

0 Answers0