didi/DoKit · error · IllegalArgumentException

file == null

Error message

file == null

What it means

invalidate(File file) converts the file to Uri.fromFile(file) and rejects null with IllegalArgumentException('file == null'). Same contract as the Uri/String overloads: cache invalidation is never a no-op API, the caller must pass the concrete cache key source. Uri.fromFile(null) would itself throw, so Picasso surfaces the argument error at its own boundary.

Source

Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java:372

   * @see #invalidate(Uri)
   * @see #invalidate(File)
   */
  public void invalidate(String path) {
    if (path == null) {
      throw new IllegalArgumentException("path == null");
    }
    invalidate(Uri.parse(path));
  }

  /**
   * Invalidate all memory cached images for the specified {@code file}.
   *
   * @see #invalidate(Uri)
   * @see #invalidate(String)
   */
  public void invalidate(File file) {
    if (file == null) {
      throw new IllegalArgumentException("file == null");
    }
    invalidate(Uri.fromFile(file));
  }

  /**
   * {@code true} if debug display, logging, and statistics are enabled.
   * <p>
   * @deprecated Use {@link #areIndicatorsEnabled()} and {@link #isLoggingEnabled()} instead.
   */
  @SuppressWarnings("UnusedDeclaration") @Deprecated public boolean isDebugging() {
    return areIndicatorsEnabled() && isLoggingEnabled();
  }

  /**
   * Toggle whether debug display, logging, and statistics are enabled.
   * <p>
   * @deprecated Use {@link #setIndicatorsEnabled(boolean)} and {@link #setLoggingEnabled(boolean)}
   * instead.

View on GitHub (pinned to 626827cddb)

Solutions

  1. Null-check the File before invalidating
  2. If the file may not exist yet, skip both invalidation and any dependent load
  3. Prefer invalidating by the exact key form used at load time (load(File) uses Uri.fromFile too, so the keys match)

Example fix

// before
DokitPicasso.with(context).invalidate(editedImageFile);

// after
if (editedImageFile != null && editedImageFile.exists()) {
  DokitPicasso.with(context).invalidate(editedImageFile);
}
Defensive patterns

Strategy: validation

Validate before calling

if (file != null && file.exists()) {
  picasso.invalidate(file);
}

Try / catch

try { picasso.invalidate(file); }
catch (IllegalArgumentException e) { /* file == null */ }

Prevention

When it happens

Trigger: picasso.invalidate((File) null); invalidate(new File(path)) where path is null producing null via a helper; cache-busting after deleting a cached image file that was never created.

Common situations: Photo-edit flows where the edited File reference is null after a failed save; cleanup routines that iterate possibly-null file references.

Related errors


AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14). Data as JSON: /api/errors/61595604fde8460e. Report an issue: GitHub.