Proguard error after adding Glide v4

Viewed 2461

I am not able to generate the apk with proguard enabled after adding glide v4 library. I have added the below lines in proguard-rules

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

It's showing the below error while building.

Warning:com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool: can't find referenced field 'android.graphics.Bitmap$Config HARDWARE' in library class android.graphics.Bitmap$Config

4 Answers

I assume you take your proguard rules from this glide page but it is miswritten. Replace below line

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

with this:

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

as you see, module package is missing. It is also properly documented on README page. You can also check your AppGlideModule class path from External Libraries.

You can as well increase your compileSdkVersion to 26. This takes care of the new features that Glide v4 uses.

Related