Android 开发使用第三方库出现Crash时处理方案汇总

一、Glide混淆脚本没加导致的Crash

现象描述:

使用Glide开发的时候在debug版本一直没事,但是realease版本各种Crash,报错信息如下:

java.lang.IllegalArgumentException: Unable to find GlideModule to find GlideModule implementation

一开始我就想到了混淆脚本,结果遇到了两个坑:

  1. 网上提供的混淆脚本包名是Glide之前的包名  
  2. Glide内部混淆没关系,但是实现了GlideModule接口的类不能混淆,因为manifest中明确的指明了包名+类名的,混淆了自然就找不到了

解决方法:

加上必要的混淆脚本:

-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.** {
    *;
}
posted @ 2018-01-04 11:50  灰色飘零  阅读(1200)  评论(0编辑  收藏  举报