{"record":{"id":"b62ad79596668f91","repo":"apache/cordova-android","slug":"uri-not-supported-by-cordovaresourceapi-uri","errorCode":null,"errorMessage":"URI not supported by CordovaResourceApi: ${uri}","messagePattern":"URI not supported by CordovaResourceApi: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"framework/src/org/apache/cordova/CordovaResourceApi.java","lineNumber":330,"sourceCode":"                int length = conn.getContentLength();\n                InputStream inputStream;\n                if (\"gzip\".equals(conn.getContentEncoding())) {\n                    inputStream = new GZIPInputStream(conn.getInputStream());\n                } else {\n                    inputStream = conn.getInputStream();\n                }\n                return new OpenForReadResult(uri, inputStream, mimeType, length, null);\n            }\n            case URI_TYPE_PLUGIN: {\n                String pluginId = uri.getHost();\n                CordovaPlugin plugin = pluginManager.getPlugin(pluginId);\n                if (plugin == null) {\n                    throw new FileNotFoundException(\"Invalid plugin ID in URI: \" + uri);\n                }\n                return plugin.handleOpenForRead(uri);\n            }\n        }\n        throw new FileNotFoundException(\"URI not supported by CordovaResourceApi: \" + uri);\n    }\n\n    public OutputStream openOutputStream(Uri uri) throws IOException {\n        return openOutputStream(uri, false);\n    }\n\n    /**\n     * Opens a stream to the given URI.\n     *\n     * @return Never returns null.\n     * @throws IllegalArgumentException For relative URIs. Relative URIs should be resolved before\n     *                                  being passed into this function.\n     * @throws IOException              If the URI cannot be opened.\n     */\n    public OutputStream openOutputStream(Uri uri, boolean append) throws IOException {\n        assertBackgroundThread();\n        switch (getUriType(uri)) {\n            case URI_TYPE_FILE: {","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/apache/cordova-android/blob/7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3/framework/src/org/apache/cordova/CordovaResourceApi.java#L312-L348","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before\nresourceApi.openForRead(Uri.parse(\"ftp://example.com/file.txt\"));\n\n// after\n// download over http, or map custom schemes in a plugin:\nresourceApi.openForRead(Uri.parse(\"https://example.com/file.txt\"));","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isOpenableUri(Uri uri) {\n    int t = CordovaResourceApi.getUriType(uri);\n    return t != CordovaResourceApi.URI_TYPE_UNKNOWN;\n    // supported: file, asset(android_assets/webview), content, resource, data, http, https, cdvplugin\n}","tryCatchPattern":"try {\n    OpenForReadResult r = resourceApi.openForRead(uri);\n} catch (FileNotFoundException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"URI not supported\")) {\n        // remap the scheme (e.g. via a plugin's remapUri) or switch to file:///https://\n    }\n}","preventionTips":["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"],"tags":["cordova","cordova-android","java","uri","resource-api"],"backgroundTag":"unsupported-uri-scheme","analyzedSha":"7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3","analyzedAt":"2026-08-22T04:57:58.868Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}