Strange error with GLIDE while loading image on production build

北城以北 提交于 2019-12-11 15:48:08

问题


After applying ProGuard on my production app. We are facing the following error on loading images from URLs

E/vw: Glide failed to load image with exception: UNABLE TO LOAD PUBLICSUFFIXES.GZ RESOURCE FROM THE CLASSPATH.

java.lang.IllegalStateException: Unable to load publicsuffixes.gz resource from the classpath.

Finally, we tried keeping the whole Glide sources in the progaurd configuration with the following command

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

But still facing the same issue.

Not sure what exactly should be done to fix the error above.

We also tried keeping the exact path as mentioned in the error by doing the following:

-keep class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

I did try various recommended solutions on the Github issues and other forums but none of them helped.


回答1:


use this in your app gradle file and it will solve the problem.

android {
    defaultConfig {
        multiDexEnabled true
    }
    packagingOptions {
        pickFirst  'META-INF/*'
        exclude "okhttp3/internal/publicsuffix/publicsuffixes.gz"
    }
}


来源:https://stackoverflow.com/questions/51720114/strange-error-with-glide-while-loading-image-on-production-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!