问题
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