Fix loading of file:// URLs in Android release#329
Closed
ckknight wants to merge 1 commit intorive-app:mainfrom
Closed
Fix loading of file:// URLs in Android release#329ckknight wants to merge 1 commit intorive-app:mainfrom
ckknight wants to merge 1 commit intorive-app:mainfrom
Conversation
This updates the definition of `RiveReactNativeView.downloadUrlAsset` to load `file://` URLs via `java.io.File` Formerly, if a `file://` URL was loaded, that would lead to `com.android.volley.VolleyError: java.lang.ClassCastException: sun.net.www.protocol.file.FileURLConnection cannot be cast to java.net.HttpURLConnection` This only affects Android apps built in release mode, as debug mode is unaffected.
|
Before this change, I receive error when run an eas update bundle: I can confirm that using this commit allows the local Rive file to be correctly loaded in EAS Update. |
|
Can't for the life of me make this work, is it supposed to just be something like this? On my component <Rive
url="file://assets/rive/logo.riv"
style={{ width: 400, height: 400 }}
/>On app.json under [
"expo-asset",
{
"assets": ["./assets/rive/logo.riv"]
}
]I have checked that the asset is loaded correctly by expo assets, and the rive component works perfectly with https:// urls, so no idea what the issue is. |
|
I used this as a patch on Rive React Native version 9.6.1 |
mfazekas
added a commit
to mfazekas/rive-react-native
that referenced
this pull request
Nov 5, 2025
Simplify PR rive-app#329 implementation by removing unnecessary factory pattern and using iOS-style approach with simple conditional dispatch. Changes: - Remove ResourceLoaderFactory, ResourceLoader interface, and implementations - Replace factory pattern with simple if/else using URI.scheme - Add loadFileUrlAsset() with background threading (Dispatchers.IO) - Add loadRemoteUrlAsset() wrapping existing Volley logic - Use proper URI parsing instead of string.startsWith() Benefits: - 50 fewer lines of code (net: -14 lines) - Matches iOS architectural pattern (simple conditional dispatch) - More maintainable - no unnecessary abstractions - Uses URI.scheme for robust URL checking vs string matching - Keeps critical improvements: background threading and error handling Threading improvements: - File I/O on Dispatchers.IO background thread - Callbacks on main thread with withContext(Dispatchers.Main) - Matches iOS pattern (DispatchQueue.global + DispatchQueue.main.async) Error handling improvements: - Check file existence and permissions before reading - Return 404 NetworkResponse for FileNotFoundException - Clear error messages for different failure modes URL parsing improvements: - Use java.net.URI instead of string.substring() - Handles edge cases: file://, file:///, URL encoding - Validates URI syntax properly - Case-insensitive scheme checking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
mfazekas
added a commit
to mfazekas/rive-react-native
that referenced
this pull request
Nov 5, 2025
Simplify PR rive-app#329 implementation by removing unnecessary factory pattern and using iOS-style approach with simple conditional dispatch. Changes: - Remove ResourceLoaderFactory, ResourceLoader interface, and implementations - Replace factory pattern with simple if/else using URI.scheme - Add loadFileUrlAsset() with background threading (Dispatchers.IO) - Add loadRemoteUrlAsset() wrapping existing Volley logic - Use proper URI parsing instead of string.startsWith() Benefits: - 50 fewer lines of code (net: -14 lines) - Matches iOS architectural pattern (simple conditional dispatch) - More maintainable - no unnecessary abstractions - Uses URI.scheme for robust URL checking vs string matching - Keeps critical improvements: background threading and error handling Threading improvements: - File I/O on Dispatchers.IO background thread - Callbacks on main thread with withContext(Dispatchers.Main) - Matches iOS pattern (DispatchQueue.global + DispatchQueue.main.async) Error handling improvements: - Check file existence and permissions before reading - Return 404 NetworkResponse for FileNotFoundException - Clear error messages for different failure modes URL parsing improvements: - Use java.net.URI instead of string.substring() - Handles edge cases: file://, file:///, URL encoding - Validates URI syntax properly - Case-insensitive scheme checking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
mfazekas
added a commit
to mfazekas/rive-react-native
that referenced
this pull request
Nov 5, 2025
Simplify PR rive-app#329 implementation by removing unnecessary factory pattern and using iOS-style approach with simple conditional dispatch. Changes: - Remove ResourceLoaderFactory, ResourceLoader interface, and implementations - Replace factory pattern with simple if/else using URI.scheme - Add loadFileUrlAsset() with background threading (Dispatchers.IO) - Add loadRemoteUrlAsset() wrapping existing Volley logic - Use proper URI parsing instead of string.startsWith() Benefits: - 50 fewer lines of code (net: -14 lines) - Matches iOS architectural pattern (simple conditional dispatch) - More maintainable - no unnecessary abstractions - Uses URI.scheme for robust URL checking vs string matching - Keeps critical improvements: background threading and error handling Threading improvements: - File I/O on Dispatchers.IO background thread - Callbacks on main thread with withContext(Dispatchers.Main) - Matches iOS pattern (DispatchQueue.global + DispatchQueue.main.async) Error handling improvements: - Check file existence and permissions before reading - Return 404 NetworkResponse for FileNotFoundException - Clear error messages for different failure modes URL parsing improvements: - Use java.net.URI instead of string.substring() - Handles edge cases: file://, file:///, URL encoding - Validates URI syntax properly - Case-insensitive scheme checking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
mfazekas
added a commit
to mfazekas/rive-react-native
that referenced
this pull request
Nov 6, 2025
Simplify PR rive-app#329 implementation by removing unnecessary factory pattern and using iOS-style approach with simple conditional dispatch. Changes: - Remove ResourceLoaderFactory, ResourceLoader interface, and implementations - Replace factory pattern with simple if/else using URI.scheme - Add loadFileUrlAsset() with background threading (Dispatchers.IO) - Add loadRemoteUrlAsset() wrapping existing Volley logic - Use proper URI parsing instead of string.startsWith() Benefits: - 50 fewer lines of code (net: -14 lines) - Matches iOS architectural pattern (simple conditional dispatch) - More maintainable - no unnecessary abstractions - Uses URI.scheme for robust URL checking vs string matching - Keeps critical improvements: background threading and error handling Threading improvements: - File I/O on Dispatchers.IO background thread - Callbacks on main thread with withContext(Dispatchers.Main) - Matches iOS pattern (DispatchQueue.global + DispatchQueue.main.async) Error handling improvements: - Check file existence and permissions before reading - Return 404 NetworkResponse for FileNotFoundException - Clear error messages for different failure modes URL parsing improvements: - Use java.net.URI instead of string.substring() - Handles edge cases: file://, file:///, URL encoding - Validates URI syntax properly - Case-insensitive scheme checking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
mfazekas
added a commit
that referenced
this pull request
Nov 6, 2025
Simplify PR #329 implementation by removing unnecessary factory pattern and using iOS-style approach with simple conditional dispatch. Changes: - Remove ResourceLoaderFactory, ResourceLoader interface, and implementations - Replace factory pattern with simple if/else using URI.scheme - Add loadFileUrlAsset() with background threading (Dispatchers.IO) - Add loadRemoteUrlAsset() wrapping existing Volley logic - Use proper URI parsing instead of string.startsWith() Benefits: - 50 fewer lines of code (net: -14 lines) - Matches iOS architectural pattern (simple conditional dispatch) - More maintainable - no unnecessary abstractions - Uses URI.scheme for robust URL checking vs string matching - Keeps critical improvements: background threading and error handling Threading improvements: - File I/O on Dispatchers.IO background thread - Callbacks on main thread with withContext(Dispatchers.Main) - Matches iOS pattern (DispatchQueue.global + DispatchQueue.main.async) Error handling improvements: - Check file existence and permissions before reading - Return 404 NetworkResponse for FileNotFoundException - Clear error messages for different failure modes URL parsing improvements: - Use java.net.URI instead of string.substring() - Handles edge cases: file://, file:///, URL encoding - Validates URI syntax properly - Case-insensitive scheme checking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates the definition of
RiveReactNativeView.downloadUrlAssetto loadfile://URLs viajava.io.FileFormerly, if a
file://URL was loaded, that would lead tocom.android.volley.VolleyError: java.lang.ClassCastException: sun.net.www.protocol.file.FileURLConnection cannot be cast to java.net.HttpURLConnectionThis only affects Android apps built in release mode, as debug mode is unaffected.