nostra13/Android-Universal-Image-Loader · error · IllegalArgumentException
decodingOptions can't be null
Error message
decodingOptions can't be null
What it means
DisplayImageOptions.Builder.decodingOptions(BitmapFactory.Options) rejects a null Options object because the builder stores it and the decoders dereference it (inPreferredConfig, inSampleSize) for every image load. Note the documented caveat: the library overrides inSampleSize itself according to imageScaleType, and decodingOptions() overlaps bitmapConfig(); passing null would leave decoding undefined.
Source
Thrown at library/src/main/java/com/nostra13/universalimageloader/core/DisplayImageOptions.java:391
}
/** Sets {@link Bitmap.Config bitmap config} for image decoding. Default value - {@link Bitmap.Config#ARGB_8888} */
public Builder bitmapConfig(Bitmap.Config bitmapConfig) {
if (bitmapConfig == null) throw new IllegalArgumentException("bitmapConfig can't be null");
decodingOptions.inPreferredConfig = bitmapConfig;
return this;
}
/**
* Sets options for image decoding.<br />
* <b>NOTE:</b> {@link Options#inSampleSize} of incoming options will <b>NOT</b> be considered. Library
* calculate the most appropriate sample size itself according yo {@link #imageScaleType(ImageScaleType)}
* options.<br />
* <b>NOTE:</b> This option overlaps {@link #bitmapConfig(android.graphics.Bitmap.Config) bitmapConfig()}
* option.
*/
public Builder decodingOptions(Options decodingOptions) {
if (decodingOptions == null) throw new IllegalArgumentException("decodingOptions can't be null");
this.decodingOptions = decodingOptions;
return this;
}
/** Sets delay time before starting loading task. Default - no delay. */
public Builder delayBeforeLoading(int delayInMillis) {
this.delayBeforeLoading = delayInMillis;
return this;
}
/** Sets auxiliary object which will be passed to {@link ImageDownloader#getStream(String, Object)} */
public Builder extraForDownloader(Object extra) {
this.extraForDownloader = extra;
return this;
}
/** Sets whether ImageLoader will consider EXIF parameters of JPEG image (rotate, flip) */
public Builder considerExifParams(boolean considerExifParams) {View on GitHub (pinned to ba33ec64d0)
Solutions
- Pass a constructed Options: .decodingOptions(new BitmapFactory.Options())
- If you only wanted the bitmap config, use .bitmapConfig(Bitmap.Config.RGB_565) instead of decodingOptions
- Initialize settings fields at declaration so they can never be null
Example fix
// before BitmapFactory.Options o = maybeInitOptions(); // returns null by default builder.decodingOptions(o); // after builder.decodingOptions(new BitmapFactory.Options()); // or, if only config matters: builder.bitmapConfig(Bitmap.Config.RGB_565);
Defensive patterns
Strategy: validation
Validate before calling
BitmapFactory.Options o = decodingOptions != null
? decodingOptions : new BitmapFactory.Options();
options.decodingOptions(o); Type guard
static boolean isUsableDecodingOptions(BitmapFactory.Options o) {
return o != null;
} Prevention
- Prefer the dedicated builder methods (bitmapConfig, imageScaleType) over raw Options
- Initialize Options eagerly where it is declared
- Remember inSampleSize is ignored — do not rely on it via decodingOptions()
When it happens
Trigger: Calling .decodingOptions(null) in an options builder chain; passing a BitmapFactory.Options field of a settings object that was never initialized; creating options lazily and forgetting the branch that leaves it null.
Common situations: Optional decoding settings modeled as null meaning 'default'; copy-pasted sample code where the Options variable was removed but the call stayed; proguard/stripping issues are NOT the cause here, it is always an explicit null argument.
Related errors
- bitmapConfig can't be null
- displayer can't be null
- key == null
- key == null || value == null
- ImageLoader configuration can not be initialized with null
AI-assisted analysis of nostra13/Android-Universal-Image-Loader@ba33ec64d0 (2026-08-14).
Data as JSON: /api/errors/42d422be9a059021.
Report an issue: GitHub.