coil-kt/coil
View on GitHubCompose Multiplatform Resources loaded with Res.getUri don't work on Windows
Open
#2833 opened on Feb 9, 2025
help wanted
Description
Discussed in https://github.com/coil-kt/coil/discussions/2824
Originally posted by nevrozza February 1, 2025 Hi! I program on a macbook, but now I've built a project for windows and now I don't have icons/images... (On other platforms (macOS, iOS, Android, WASM, JS) everything is OK).
/*"jar:file:/Users/nevrozq/Code/PansionApp/common/utils-compose/build/libs/utils-compose-jvm.jar!/composeResources/pansion/drawable/icons/screwdriver-wrench-solid.svg"*/
val uri = Res.getUri("drawable/icons/${path}")
AsyncImage(
ImageRequest.Builder(LocalPlatformContext.current)
.data(uri)
.build(),
// other params
)
Throws:
java.lang.IllegalStateException: Unable to create a fetcher that supports: jar:file:/C:/Users/harla/OneDrive/Desktop/PansionApp/composeApp/build/compose/binaries/main-release/app/PansionApp/app/utils-compose-jvm-441ba4d5932399cabbfe401536893dcf.jar!/composeResources/pansion/drawable/icons/trophy-solid.svg
I guess the problem is that the project is multi-module and Res.getUri("drawable/icons/${path}") returns svg from a jar file. However, it still works on other platforms
Very important: If I use url link from internet or put path to picture (not in jar) it works...
So... There is a crutch solution!
Make a separate Windows-only folder with resources and transfer it simply as a string uri = "resources\\drawable\\icons\\${path}"...... But I still believe there is a better solution.
Thanks!