Using Glide with Kotlin

Vlonjat Gashi
1 min readDec 28, 2017

--

Glide is an image-loading library for Android that simplifies the process of loading and displaying images from external sources. It’s highly customizable and efficient, making it a popular choice among Android developers.

In version 4, Glide received massive API changes that slightly changed how we can use it in our apps. To make it work with Kotlin, follow these steps:

First, you’ll need to add the Glide dependency to your app-level build.gradle file:

implementation 'com.github.bumptech.glide:glide:4.4.0'
kapt 'com.github.bumptech.glide:compiler:4.4.0'

Include the kotlin-kapt plugin in your build.gradle file:

apply plugin: 'kotlin-kapt'

Create an AppGlideModule implementation:

import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.module.AppGlideModule

@GlideModule
class AppGlideModule : AppGlideModule()

Build the project and then use the generated API:

GlideApp.with(this)
.load(URL)
.into(image)

To learn more about using Glide with Kotlin, check out the official documentation at https://bumptech.github.io/glide/. There, you can find more advanced examples and explore the full range of features offered by the library.

Thank you for reading. If you enjoyed this post, please consider 
following for more content like this.

--

--