coil: [Coil 3] Local image files don't show on PC
Describe the bug
Hello!
Local image files don’t show on PC.
Error type is not in the function error()
To Reproduce
val platformContext = LocalPlatformContext.current
val uri = "file:///H:/1.png".toUri()
val request = ImageRequest.Builder(platformContext)
.data(uri)
.error {
println("error")
null
}.build()
AsyncImage(
model = request,
contentDescription = "",
contentScale = ContentScale.FillHeight,
modifier = Modifier.fillMaxSize()
)
Logs/Screenshots
Version Coil 3.0.0-alpha01
kotlin.version=1.9.21 agp.version=8.1.4 compose.version=1.5.11
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25 (2 by maintainers)
Possible workaround to use normal windows path.
Create a custom fetcher:
Register it:
It’s just a subfolder of the working directory of my app, nothing special.
This workaround is fine in my Windows, but I suppose it will break anywhere else.
Same here. Compose for Desktop in a Windows 11 machine.
This shows nothing in my UI, but outputs the following error:
I’m positive the file is OK, because I’m scanning a folder, and I’m migrating from another image loader that displayed it with no problem. Also, if I pass an URL of a remote image, it loads and displays perfectly fine.
I run into the exact same problem. I am on
3.0.0-alpha04implementing a KMP project targeting Windows and Android.The file I want to show on Windows is located at
"C:\Users\<user>\AppData\Roaming\<project>\Thumbnails\tool2019fearinoculum.jpg"(c+p from file explorer)When I run
or
it returns
true. However, when I run one of the above like thisit gives me
throwable=java.lang.IllegalStateException: Unable to create a fetcher that supports: file://C:\Users\<user>\AppData\Roaming\<project>\Thumbnails\tool2019fearinoculum.jpg.I agree with @ejektaflex. If I am not doing anything completely wrong, I would also assume this code to work.
Edit: Putting
file://C:\Users\<user>\AppData\Roaming\<project>\Thumbnails\tool2019fearinoculum.jpginto the browser shows the image. Passing it as the model parameter, however, does not work.I just had the same issue, it’s nice to know that it wasn’t me. I’m using 3.0.0-Alpha 04.
When passing in a
File, Coil fails to load the image on Jetbrains Compose (JVM) on Windows.I had to do this to get it to work:
I would assume that we should expect to just pass a File object to Coil, and it would work correctly, right?
It definitely does not seem to like Windows file paths.