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

Step 1. Implement dependency

repositories {

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

dependencies {
implementation "dev.chrisbanes.accompanist:accompanist-coil:<version>"

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):

<uses-permission android:name="android.permission.INTERNET"/>

Step 3. Put it where you need it

  • Simple Declaration
data = "",
contentDescription = "Random adorable cat"
  • Fill parent with custom size
modifier = Modifier
.padding(bottom = 15.dp)
) {
data = "",
contentDescription = "Random cute yorkshire",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,

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