Implements Glide 4.10.0 in AndroidX had error GeneratedAppGlideModuleImpl is implemented incorrectly

Viewed 1170

I had problem when implement Glide 4.10.0 in AndroidX, I had following the documentation but still getting error. Please Help I new in Glide !!

My proguard-rules.pro code

-keep public class * implements com.bumptech.glide.module.GlideModule

-keep public class * extends com.bumptech.glide.module.AppGlideModule

-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

My build.gradle code

 implementation 'com.github.bumptech.glide:glide:4.10.0'

 annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

My Code

Glide.with(ctx).load("https://lh6.ggpht.com/9SZhHdv4URtBzRmXpnWxZcYhkgTQurFuuQ8OR7WZ3R7fyTmha77dYkVvcuqMu3DLvMQ=w300").into(img);

ERROR MESSAGE

W/System.err: java.lang.IllegalStateException: GeneratedAppGlideModuleImpl is implemented incorrectly. If you've manually implemented this class, remove your implementation. The Annotation processor will generate a correct implementation.
        at com.bumptech.glide.Glide.throwIncorrectGlideModule(Glide.java:341)
        at com.bumptech.glide.Glide.getAnnotationGeneratedGlideModules(Glide.java:333)
        at com.bumptech.glide.Glide.get(Glide.java:176)
        at com.bumptech.glide.Glide.getRetriever(Glide.java:714)
        at com.bumptech.glide.Glide.with(Glide.java:741)
        at com.ind.projecttest.util.Tools.displayCircularImageViewOriginal(Tools.java:62)
        at com.ind.projecttest.activity.MainActivity.setupLayoutValue(MainActivity.java:101)
        at com.ind.projecttest.activity.MainActivity.access$500(MainActivity.java:54)
        at com.ind.projecttest.activity.MainActivity$4.onResponse(MainActivity.java:305)
        at com.ind.projecttest.activity.MainActivity$4.onResponse(MainActivity.java:296)
        at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:90)
        at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:102)
W/System.err:     at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
    Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context]
        at java.lang.Class.getConstructor0(Class.java:2327)
        at java.lang.Class.getDeclaredConstructor(Class.java:2166)
        at com.bumptech.glide.Glide.getAnnotationGeneratedGlideModules(Glide.java:317)
        ... 17 more
I/f.indsmartmobil: ProcessProfilingInfo new_methods=1978 is saved saved_to_disk=1 resolve_classes_delay=8000
W/DpmTcmClient: read failed bytes countRead: -1
1 Answers

Adding the @Keep annotation in my custom AppGlideModule class worked for me.

@Keep
@GlideModule
class AppGlideModule : AppGlideModule() {

}
Related