apache/cordova-android · error · FileNotFoundException
URI not supported by CordovaResourceApi: ${uri}
Error message
URI not supported by CordovaResourceApi: ${uri} What it means
The fall-through of CordovaResourceApi.openForRead: the method handles file, asset, content, resource (android_res), data, http, https, and cdvplugin URIs; any URI whose type classifies as URI_TYPE_UNKNOWN (or an unrecognized combination) reaches the final throw. It means the read request's scheme/shape is simply not in the supported set.
Source
Thrown at framework/src/org/apache/cordova/CordovaResourceApi.java:330
int length = conn.getContentLength();
InputStream inputStream;
if ("gzip".equals(conn.getContentEncoding())) {
inputStream = new GZIPInputStream(conn.getInputStream());
} else {
inputStream = conn.getInputStream();
}
return new OpenForReadResult(uri, inputStream, mimeType, length, null);
}
case URI_TYPE_PLUGIN: {
String pluginId = uri.getHost();
CordovaPlugin plugin = pluginManager.getPlugin(pluginId);
if (plugin == null) {
throw new FileNotFoundException("Invalid plugin ID in URI: " + uri);
}
return plugin.handleOpenForRead(uri);
}
}
throw new FileNotFoundException("URI not supported by CordovaResourceApi: " + uri);
}
public OutputStream openOutputStream(Uri uri) throws IOException {
return openOutputStream(uri, false);
}
/**
* Opens a stream to the given URI.
*
* @return Never returns null.
* @throws IllegalArgumentException For relative URIs. Relative URIs should be resolved before
* being passed into this function.
* @throws IOException If the URI cannot be opened.
*/
public OutputStream openOutputStream(Uri uri, boolean append) throws IOException {
assertBackgroundThread();
switch (getUriType(uri)) {
case URI_TYPE_FILE: {View on GitHub (pinned to 7c1e190064)
Solutions
- Convert the request to a supported scheme before opening: file://, content://, android.resource://, data:, http(s)://, or cdvplugin://
- For custom schemes, implement remapUri() in a CordovaPlugin to translate your scheme into one of the supported types before CordovaResourceApi sees it
Example fix
// before
resourceApi.openForRead(Uri.parse("ftp://example.com/file.txt"));
// after
// download over http, or map custom schemes in a plugin:
resourceApi.openForRead(Uri.parse("https://example.com/file.txt")); Defensive patterns
Strategy: type-guard
Type guard
static boolean isOpenableUri(Uri uri) {
int t = CordovaResourceApi.getUriType(uri);
return t != CordovaResourceApi.URI_TYPE_UNKNOWN;
// supported: file, asset(android_assets/webview), content, resource, data, http, https, cdvplugin
} Try / catch
try {
OpenForReadResult r = resourceApi.openForRead(uri);
} catch (FileNotFoundException e) {
if (e.getMessage() != null && e.getMessage().contains("URI not supported")) {
// remap the scheme (e.g. via a plugin's remapUri) or switch to file:///https://
}
} Prevention
- Whitelist schemes at your app boundary before passing URIs to CordovaResourceApi
- Implement remapUri() for custom schemes
- Resolve relative links before they reach the resource API
When it happens
Trigger: Calling openForRead/processUri with a URI of an unsupported scheme (e.g. ftp://, ws://, javascript:, intent:, about:, customapp://) or a malformed URI whose getUriType returns UNKNOWN; also custom schemes no plugin has remapped beforehand.
Common situations: WebView or native code passing through arbitrary hrefs; third-party plugins with bespoke schemes expecting cordova to fetch them; debugging with javascript: or chrome-extension: URIs; typo'd scheme (file:/ vs file:// is tolerated, but httpss:// is not).
Related errors
- Plugin can't handle uri: ${uri}
- Invalid plugin ID in URI: ${uri}
- Relative URIs are not supported.
- Do not perform IO operations on the UI thread. Use CordovaIn
- Tried to perform an IO operation on the WebCore thread. Use
AI-assisted analysis of apache/cordova-android@7c1e190064 (2026-08-22).
Data as JSON: /api/errors/b62ad79596668f91.
Report an issue: GitHub.