Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose Multiplatform Resources loaded with Res.getUri don't work on Windows #2833

Open
colinrtwhite opened this issue Feb 9, 2025 · 0 comments

Comments

@colinrtwhite
Copy link
Member

Discussed in #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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant