-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[android] Using asset:// URL with path outside of APK #6273
Comments
@1ec5 It's been a week, so I'm just checking in. Does this issue make sense? Should I clarify? Or Is everything working as intended and I need to find another way to make my use case work? Or is everyone too busy right now to look into my little issue here? |
Hi @BigSassy, unfortunately, I’m not very familiar with the Android side, since I usually work on the iOS and macOS SDKs. The cross-platform components of Mapbox GL allow you to specify an absolute path to an asset. For example, a style URL of |
@1ec5 Thanks for answering. No, that doesn't seem to work for me (but I would LOVE to be wrong about this). From what I've read, you are confined to anything bundled with the APK when utilizing @ljbade Since you appear to be one of the main people involved with this part of the codebase, do you have any insight here? I base this on your activity in issue #579. |
@1ec5: In android the asset:// urls are handled differently. The asset:// urls load resources basically from the android zip resource file which is bundled with an application. This zip is opened and the file is read from there, and it is impossible for an application to modify it. @BigSassy: I believe you are correct, there is no nice way to load resources, like styles, which have been downloaded. In order to get the same functionality as iOS has, I've actually been forced to implement a web server locally, and loading assets from http://localhost:12345/myfile type urls. Yes this is ugly, but it is currently the only way to do on android what is really easy in iOS. |
For reference, here's the android specific implementation https://github.com/mapbox/mapbox-gl-native/blob/29f4204d1c807109cdbe555f760744f0c928b548/platform/android/src/asset_file_source.cpp |
@cammace @zugaldia, is there any other way to refer to a local file that isn’t part of the .apk? For what it’s worth, the iOS and macOS SDKs had the same limitation until #6026. If it comes down to what |
For comparison, the iOS and macOS SDKs use the default, cross-platform implementation of |
Right. The In order to support arbitrary files that the app has access to, but are outside the app package, I suggest we add a third type of source, say a How does this sound? |
I think it would be good for all the platforms to use the file: scheme for absolute paths and asset: only for things in the asset directory. The way asset: is overloaded in the default implementation feels like a hack to me. (If not for the special requirements that the Android SDK has for pulling resources out of the APK, I’d even argue that we should remove the asset: scheme in favor of absolute paths via file:.) /cc @jfirebaugh |
Platform: Android
Mapbox SDK version: react-native-mapbox-gl 5.0.0 which uses mapbox-android-sdk 4.1.1
Issue
The only way to access local files on Android via
asset://
is if it's bundled with the APK. Since you can't modify the APK from the app, Android currently doesn't support assets that have been downloaded after the app is installed.On iOS, I've been able to specify a path where files were downloaded onto the user's device, so no issues there.
My Use Case
In the app I'm developing, a user has to log in. Afterwards, the app will use their account information to generate the user's style and tilejson files along with downloading a set of vector tiles.
On iOS, I can point the
asset://
URL to these generated and downloaded files, and everything works great. But on Android, there's not a way to shove these files into the signed APK programatically.Am I missing something obvious to make this use case work on Android? Or am I hampered by
asset://
only allowing access to pre-bundled APK assets?The text was updated successfully, but these errors were encountered: