coil-kt/coil

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

Open

#2,833 建立於 2025年2月9日

在 GitHub 查看
 (6 留言) (5 反應) (0 負責人)Kotlin (757 fork)batch import
help wanted

倉庫指標

Star
 (11,779 star)
PR 合併指標
 (平均合併 20小時 14分鐘) (30 天內合併 28 個 PR)

描述

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!

貢獻者指南