didi/DoKit · warning · FileNotFoundException

No package provided: " + data.uri

Error message

No package provided: " + data.uri

What it means

Utils.getResourceId(Resources, Request) resolves an android.resource:// URI back to a resource ID for resource-request loading. If the URI has no authority segment (data.uri.getAuthority() == null) there is no package name to look the resource up in, so the method throws FileNotFoundException('No package provided: <uri>'). It surfaces as the error path of the image request (typically wrapped in the request's error handling) rather than a crash.

Source

Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Utils.java:338

  static boolean isWebPFile(InputStream stream) throws IOException {
    byte[] fileHeaderBytes = new byte[WEBP_FILE_HEADER_SIZE];
    boolean isWebPFile = false;
    if (stream.read(fileHeaderBytes, 0, WEBP_FILE_HEADER_SIZE) == WEBP_FILE_HEADER_SIZE) {
      // If a file's header starts with RIFF and end with WEBP, the file is a WebP file
      isWebPFile = WEBP_FILE_HEADER_RIFF.equals(new String(fileHeaderBytes, 0, 4, "US-ASCII"))
          && WEBP_FILE_HEADER_WEBP.equals(new String(fileHeaderBytes, 8, 4, "US-ASCII"));
    }
    return isWebPFile;
  }

  static int getResourceId(Resources resources, Request data) throws FileNotFoundException {
    if (data.resourceId != 0 || data.uri == null) {
      return data.resourceId;
    }

    String pkg = data.uri.getAuthority();
    if (pkg == null) throw new FileNotFoundException("No package provided: " + data.uri);

    int id;
    List<String> segments = data.uri.getPathSegments();
    if (segments == null || segments.isEmpty()) {
      throw new FileNotFoundException("No path segments: " + data.uri);
    } else if (segments.size() == 1) {
      try {
        id = Integer.parseInt(segments.get(0));
      } catch (NumberFormatException e) {
        throw new FileNotFoundException("Last path segment is not a resource ID: " + data.uri);
      }
    } else if (segments.size() == 2) {
      String type = segments.get(0);
      String name = segments.get(1);

      id = resources.getIdentifier(name, type, pkg);
    } else {
      throw new FileNotFoundException("More than two path segments: " + data.uri);

View on GitHub (pinned to 626827cddb)

Solutions

  1. Use the supported resource forms: picasso.load(R.drawable.foo) directly, or a correctly formed URI Uri.parse("android.resource://com.example.app/drawable/foo").
  2. Prefer the resource-ID overload whenever the resource is local — it avoids URI parsing entirely.
  3. If constructing URIs, validate them (uri.getAuthority() != null) before handing them to Picasso.

Example fix

// before
Uri uri = Uri.parse("android.resource:///" + R.drawable.foo); // no package
picasso.load(uri).into(imageView);

// after
picasso.load(R.drawable.foo).into(imageView);
// or
Uri uri = new Uri.Builder().scheme("android.resource").authority(context.getPackageName())
        .appendPath("drawable").appendPath("foo").build();
picasso.load(uri).into(imageView);
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidResourceUri(Uri uri) {
    return "android.resource".equals(uri.getScheme()) && uri.getAuthority() != null;
}
if (!isValidResourceUri(uri)) uri = fallbackLocalRes;

Try / catch

FileNotFoundException surfaces via the request error path — attach .error(resId) or a Target/onBitmapFailed handler and log the offending URI.

Prevention

When it happens

Trigger: Passing a malformed resource URI to Picasso, e.g. Uri.parse("android.resource://" + resId) without a package, or "android.resource:///drawable/name" — the authority (package) component is empty.

Common situations: Hand-building android.resource URIs via string concatenation and forgetting the package segment; copying a content:// or file:// pattern and adapting it incorrectly; a URI produced by another component that drops the authority.

Related errors


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