title: OutofMemoryError, bitmap size exceeds VM budget. in a frame animation
body: <p>I have an <code>AnimationDrawable</code> that loads few frames from the drawable resources, but on some devices I get <code>OutofMemoryError: bitmap size exceeds VM budget.</code><br/>
  Now I've read the <a href="http://developer.android.com/training/displaying-bitmaps/index.html" rel="nofollow">Displaying Bitmaps Efficiently</a> guide but I can't relate it to my case? </p>
  
  <pre><code>if (animation == null)
          animation = new AnimationDrawable();
  
      for (int i = 0; i &lt;= numOfFrames; i++){
          int resourceID = 
                  context.getResources().getIdentifier(frameName + i, "drawable" ,
                          context.getPackageName());
          animation.addFrame(context.getResources().getDrawable(resourceID), 
                  frameDuration);
      }
      animation.setOneShot(false);
  
      if(Build.VERSION.SDK_INT &gt;= 16)
          pb.setBackground(animation);
      else
          pb.setBackgroundDrawable(animation);
  
      animation.start();
  </code></pre>