{"record":{"id":"ce488f3fcf21d6e5","repo":"Yalantis/uCrop","slug":"invalid-uri-scheme-s","errorCode":null,"errorMessage":"Invalid Uri scheme%s","messagePattern":"Invalid Uri scheme(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java","lineNumber":166,"sourceCode":"        Log.d(TAG, \"Uri scheme: \" + mInputUri.getScheme());\n        if (isDownloadUri(mInputUri)) {\n            try {\n                downloadFile(mInputUri, mOutputUri);\n            } catch (NullPointerException | IOException e) {\n                Log.e(TAG, \"Downloading failed\", e);\n                throw e;\n            }\n        } else if (isContentUri(mInputUri)) {\n            try {\n                copyFile(mInputUri, mOutputUri);\n            } catch (NullPointerException | IOException e) {\n                Log.e(TAG, \"Copying failed\", e);\n                throw e;\n            }\n        } else if (!isFileUri(mInputUri)) {\n            String inputUriScheme = mInputUri.getScheme();\n            Log.e(TAG, \"Invalid Uri scheme \" + inputUriScheme);\n            throw new IllegalArgumentException(\"Invalid Uri scheme\" + inputUriScheme);\n        }\n    }\n\n    private void copyFile(@NonNull Uri inputUri, @Nullable Uri outputUri) throws NullPointerException, IOException {\n        Log.d(TAG, \"copyFile\");\n\n        if (outputUri == null) {\n            throw new NullPointerException(\"Output Uri is null - cannot copy image\");\n        }\n\n        InputStream inputStream = null;\n        OutputStream outputStream = null;\n        try {\n            inputStream = mContext.getContentResolver().openInputStream(inputUri);\n            if (inputStream == null) {\n                throw new NullPointerException(\"InputStream for given input Uri is null\");\n            }\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java#L148-L184","documentation":"BitmapLoadTask.processInputUri only supports http(s), file, and content URIs; anything else is logged and rejected with this IllegalArgumentException (note: the scheme is concatenated without a space, so the message reads e.g. 'Invalid Uri schemepackage:...'). uCrop cannot decode or copy bitmap data from an unsupported scheme.","triggerScenarios":"Passing a source Uri whose scheme is not http, https, file, or content to UCrop.of()/BitmapLoadTask — e.g. asset://, res://, data:, android.resource://, or a bare path string wrapped in Uri.parse().","commonSituations":"Wrapping a relative or absolute filesystem path with Uri.parse instead of Uri.fromFile; using bundled asset or drawable resource URIs; receiving a URI from a third-party SDK with an exotic scheme.","solutions":["Convert the path to a file URI: Uri.fromFile(new File(path)).","Copy assets/resources into a real file and pass Uri.fromFile of the copy.","Use a FileProvider to expose the resource as a content:// URI and pass that.","Log the actual inputUri.getScheme() and make sure it is http, https, file, or content before launching uCrop."],"exampleFix":"// before\nUCrop.of(Uri.parse(\"/storage/emulated/0/DCIM/photo.jpg\"), destUri);\n// after\nUCrop.of(Uri.fromFile(new File(\"/storage/emulated/0/DCIM/photo.jpg\")), destUri);","handlingStrategy":"validation","validationCode":"String scheme = inputUri != null ? inputUri.getScheme() : null;\nif (!\"http\".equals(scheme) && !\"https\".equals(scheme) && !\"file\".equals(scheme) && !\"content\".equals(scheme)) {\n    throw new IllegalArgumentException(\"Unsupported uCrop input scheme: \" + scheme);\n}","typeGuard":"boolean isSupportedForUCrop(android.net.Uri uri) {\n    if (uri == null || uri.getScheme() == null) return false;\n    String s = uri.getScheme().toLowerCase();\n    return s.equals(\"http\") || s.equals(\"https\") || s.equals(\"file\") || s.equals(\"content\");\n}","tryCatchPattern":"try {\n    UCrop.of(inputUri, outputUri).start(activity);\n} catch (IllegalArgumentException e) {\n    Toast.makeText(activity, \"Unsupported image source\", Toast.LENGTH_SHORT).show();\n}","preventionTips":["Use Uri.fromFile() for filesystem paths; never Uri.parse() a raw path.","Convert asset:// or res:// sources to a local file or FileProvider content:// URI first.","Log/inspect getScheme() before launching uCrop during integration.","Centralize source-Uri creation in one helper that guarantees a supported scheme."],"tags":["android","ucrop","uri","scheme","bitmap-load"],"backgroundTag":"invalid-url-format","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}