Jetpack Compose Tips: Load an image from URL using Coil — fast and easy

Step 1. Implement dependency

  1. Add mavenCentral() on build.gradle (project level)

2. Implement the dependency on build.gradle (app level) . Check the latest version in the repository

Step 2. Add internet permission

In your app’s AndroidManifest.xml add the internet permission inside the <manifest> tag (preferably, place it above the <application> tag):

Step 3. Put it where you need it

  • Simple Declaration
  • Fill parent with custom size

Read more about ContentScale

More of Coil functionalities:

Why use Coil?

Fast: Coil performs a number of optimizations including memory and disk caching, downsampling the image in memory, re-using bitmaps, automatically pausing/cancelling requests, and more.

Lightweight: Coil adds ~2000 methods to your APK (for apps that already use OkHttp and Coroutines), which is comparable to Picasso and significantly less than Glide and Fresco.

Easy to use: Coil’s API leverages Kotlin’s language features for simplicity and minimal boilerplate.

Modern: Coil is Kotlin-first and uses modern libraries including Coroutines, OkHttp, Okio, and AndroidX Lifecycles.

Coil is an acronym for: Coroutine Image Loader.

Read more : Coil

I personally use it in my project —

Hello, I’m MJ (just a noobie), still learning about Jetpack Compose. I will try to share anything useful that I’ve learned during this process. Leave a clap/comment/suggestions to improve my skills! Thank you :)

Android Developer | Newbie