Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference: GlideApp in activity written in Kotlin

In short my problem is that I can't use GlideApp (generated API) in an activity written in Kotlin.

Interesting enough that Android Studio sees the reference, i can open the generated GlideApp, there is code completion, but when I try to build it, then it fails with

"Unresolved reference: GlideApp"

The glide module was implemented in java since most of the apps code is written in java.

Any idea?

like image 596
Alex Avatar asked Feb 09 '18 13:02

Alex


3 Answers

Are using kapt instead of annotationprocessor in gradle file? V4 Generated API support Kotlin

like image 187
karandeep singh Avatar answered Nov 09 '22 05:11

karandeep singh


For those like me who had used kapt as suggested by karandeep but still had the problem - you have to create an AppGlideModule implementation:

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

@GlideModule
class AppGlideModule : AppGlideModule()

After rebuilding the project GlideApp can be imported (generated code).

More at this medium post

like image 23
kip2 Avatar answered Nov 09 '22 04:11

kip2


whoever still facing issue after extending AppGlideModule and adding

kapt 'com.github.bumptech.glide:compiler:4.8.0'

then don't forget to include

apply plugin: 'kotlin-kapt'

on top in app or module build.gradle

like image 21
dastan Avatar answered Nov 09 '22 06:11

dastan