Glide is the best image loading library for Android. On version 4, Glide received huge API changes that slightly changed how we can use it in our apps. To make it work with Kotlin, follow these steps:
- Include the Glide dependencies, including the annotation processor:
dependencies { implementation 'com.github.bumptech.glide:glide:4.4.0' kapt 'com.github.bumptech.glide:compiler:4.4.0' }
2. Include the
kotlin-kapt
plugin in your build.gradle
file:apply plugin: 'kotlin-kapt'
3. Create a
AppGlideModule
implementation:import com.bumptech.glide.annotation.GlideModule import com.bumptech.glide.module.AppGlideModule @GlideModule class AppGlideModule : AppGlideModule()
4. Build the project and then use the generated API:
GlideApp.with(this) .load(URL) .into(image)
No comments:
Post a Comment