NoSuchMethodError when I use android.widget.RelativeLayout.setBackground

That was added in API 16, try setBackgroundDrawable()


Try this, it worked for me:

Bitmap bitmap = BitmapFactory.decodeFile(new ImageLoader().fullPath + "/desiredFilename.png");
Resources res = getResources();
BitmapDrawable bitmapDrawable = new BitmapDrawable(res, bitmap);
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN)
   ll.setBackgroundDrawable(bitmapDrawable);
else 
   ll.setBackground(bitmapDrawable);

In addition to @dmon answer: you could call the proper method in this way:

if (Build.VERSION.SDK_INT >= 16) {

    layout.setBackground(animation);

} else {

    layout.setBackgroundDrawable(animation);
}