https://kotlinlang.org logo
#compose
Title
# compose
l

Lukasz Kalnik

02/04/2022, 6:56 PM
Can I enable logging for
AsyncImage
in coil-compose?
j

Joshua Donlan

02/04/2022, 7:10 PM
what are you trying to do? you can hook it into the httpd resolver if you wanted to log everything
what are you trying to do? you can hook it into the httpd resolver if you wanted to log everything
l

Lukasz Kalnik

02/04/2022, 8:19 PM
I wanted to see why it doesn't load the images on the Android emulator.
It only loads them when I add the following line to AndroidManifest:
Copy code
android:usesCleartextTraffic="true"
z

Zun

02/04/2022, 9:07 PM
You sure you're loading https links? No reason not to have it
l

Lukasz Kalnik

02/04/2022, 11:49 PM
Yes, sure.

https://image.tmdb.org/t/p/w780/sjx6zjQI2dLGtEL0HGWsnq6UyLU.jpg

y

yschimke

02/05/2022, 3:14 PM
It doesn't look like it, but there is always a chance that OkHttpClient is handling redirects. You could add an event listener to see exactly what is going on. https://square.github.io/okhttp/4.x/okhttp/okhttp3/-event-listener/
And also set
Copy code
OkHttpClient.Builder().followSslRedirects(false).build()
FWIW in my coil usage with 3rd party controlled images, I've had to set an interceptor to force SSL as some content specifies http URLs.
l

Lukasz Kalnik

02/06/2022, 2:06 PM
From Coil's author's response it looks like the Android emulator's security provider might be at fault here: https://github.com/coil-kt/coil/issues/1126#issuecomment-1030726847
Update: it's actually the fact that Android emulator seems to not synchronize date and time with the network. After setting the time/date manually to the current one, images started working. Also cold booting the emulator might help (looks like booting from a saved image for some reason sets the date/time to the one from when the image was saved).
BTW logging in Coil can be easily enabled by setting a custom singleton
ImageLoader
with an
HttpLoggingInterceptor
in your
Application
class: https://coil-kt.github.io/coil/getting_started/#singleton
15 Views