{"record":{"id":"e7d32c9636d33586","repo":"airbnb/lottie-android","slug":"you-must-set-an-images-folder-before-loading-an-im","errorCode":null,"errorMessage":"You must set an images folder before loading an image. Set it with LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder","messagePattern":"You must set an images folder before loading an image\\. Set it with LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java","lineNumber":129,"sourceCode":"        bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, opts);\n      } catch (IllegalArgumentException e) {\n        Logger.warning(\"Unable to decode image `\" + id + \"`.\", e);\n        return null;\n      }\n\n      if (bitmap == null) {\n        Logger.warning(\"Decoded image `\" + id + \"` is null.\");\n        return null;\n      }\n\n      Bitmap resizedBitmap = Utils.resizeBitmapIfNeeded(bitmap, asset.getWidth(), asset.getHeight());\n      return putBitmap(id, resizedBitmap);\n    }\n\n    InputStream is;\n    try {\n      if (TextUtils.isEmpty(imagesFolder)) {\n        throw new IllegalStateException(\"You must set an images folder before loading an image.\" +\n            \" Set it with LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder\");\n      }\n      is = context.getAssets().open(imagesFolder + filename);\n    } catch (IOException e) {\n      Logger.warning(\"Unable to open asset.\", e);\n      return null;\n    }\n\n    try {\n      bitmap = BitmapFactory.decodeStream(is, null, opts);\n    } catch (IllegalArgumentException e) {\n      Logger.warning(\"Unable to decode image `\" + id + \"`.\", e);\n      return null;\n    }\n    if (bitmap == null) {\n      Logger.warning(\"Decoded image `\" + id + \"` is null.\");\n      return null;\n    }","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/airbnb/lottie-android/blob/05ea92e90381eb8a8ae06855ea2b74f322bebbec/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java#L111-L147","documentation":"Thrown by ImageAssetManager when it tries to load an image asset referenced by the animation but imagesFolder is empty. Lottie animations can reference external bitmaps by filename; to resolve them from the app's assets, a folder prefix must be configured so the manager can open imagesFolder + filename.","triggerScenarios":"Playing an animation whose JSON references image assets (an \"assets\" array with \"p\" filenames and an ImageAsset delegate) without first calling LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder; or providing bitmaps via a custom ImageAssetDelegate but the manager still hits the folder-based fallback path.","commonSituations":"Loading a Lottie with embedded image references but forgetting to bundle/place the images in assets and set the folder; renaming the assets folder without updating the call; using a custom delegate that returns null for an id so the manager falls back to file loading.","solutions":["Place the referenced images in an assets subfolder and call lottieDrawable.setImagesFolder(\"images/\") (or composition.setImagesFolder) before playback.","If you supply bitmaps programmatically, register an ImageAssetDelegate via setImageAssetDelegate so the manager uses your bitmaps instead of the assets folder.","Confirm the folder string ends with a separator (\"images/\") since the manager concatenates imagesFolder + filename directly.","Verify each image's \"p\" filename in the JSON matches a file in that folder."],"exampleFix":"// before\nlottieAnimationView.setAnimation(R.anim.with_images);\nlottieAnimationView.playAnimation(); // throws on first image asset\n\n// after\nlottieAnimationView.setAnimation(R.anim.with_images);\nlottieAnimationView.setImageAssetsFolder(\"images/\");\nlottieAnimationView.playAnimation();","handlingStrategy":"validation","validationCode":"// Ensure the folder is set before any image-bearing animation plays\nif (compositionHasImageAssets(lottieAnimationView.getComposition())) {\n  lottieAnimationView.setImageAssetsFolder(\"images/\");\n}\nboolean compositionHasImageAssets(LottieComposition c) {\n  return c != null && c.getImages() != null && !c.getImages().isEmpty();\n}","typeGuard":"boolean needsImagesFolder(LottieComposition c) {\n  return c != null && c.getImages() != null && !c.getImages().isEmpty();\n}","tryCatchPattern":null,"preventionTips":["Call setImageAssetsFolder before playAnimation whenever the asset references images.","End the folder string with a separator (\"images/\").","Bundle the exact filenames referenced by the JSON's \"p\" fields.","Alternatively register an ImageAssetDelegate to supply bitmaps in code."],"tags":["image-assets","composition","assets","configuration"],"backgroundTag":null,"analyzedSha":"05ea92e90381eb8a8ae06855ea2b74f322bebbec","analyzedAt":"2026-08-14T00:51:35.636Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}