diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapFactory.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapFactory.java index 429a858b2eb..3be32942fdb 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapFactory.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapFactory.java @@ -75,7 +75,8 @@ protected static Bitmap decodeResource(Resources res, int id, BitmapFactory.Opti final TypedValue value = new TypedValue(); InputStream is = res.openRawResource(id, value); - RobolectricBufferedImage image = getImageFromStream(res.getResourceName(id), is); + String resourceName = res.getResourceName(id); + RobolectricBufferedImage image = getImageFromStream(resourceName, is); if (!allowInvalidImageData && image == null) { if (options != null) { options.outWidth = -1; @@ -83,7 +84,7 @@ protected static Bitmap decodeResource(Resources res, int id, BitmapFactory.Opti } return null; } - Bitmap bitmap = create("resource:" + res.getResourceName(id), options, image); + Bitmap bitmap = create("resource:" + resourceName, options, image); ShadowBitmap shadowBitmap = Shadow.extract(bitmap); shadowBitmap.createdFromResId = id; return bitmap;