Glide的 java.lang.RuntimeException: Expected instanceof GlideModule, but found:X.GlideModule@2e4554f

问题一

在添加过混淆规则后,App打包的时候,发现报错了

     java.lang.RuntimeException: Expected instanceof GlideModule, but found: com.kevin.play.view.GlideModule@2e4554f
     at com.bumptech.glide.module.ManifestParser.parseModule(ManifestParser.java:87)
     at com.bumptech.glide.module.ManifestParser.parse(ManifestParser.java:47)

这意思是ManifestParser解析出问题了,可以看到

 /**
   * Returns {@code true} if Glide should check the AndroidManifest for {@link GlideModule}s.
   *
   * <p>Implementations should return {@code false} after they and their dependencies have migrated
   * to Glide's annotation processor.
   *
   * <p>Returns {@code true} by default.
   */
   public boolean isManifestParsingEnabled() {
    return true;
  }

依赖中使用了Glide的 annotation processor.需要在他的实现类里返回false
所以解决方案是在你自己写的实现AppGlideModule那个类中添加如下方法即可:

   @Override
    public boolean isManifestParsingEnabled() {
        return false;
    }

问题二:

Unresolved reference GlideApp

解决完问题一,发现又报了问题二
原来是需要在Glide的Moudle处进行make project.
需要在使用Glide的地方使用GlideApp
make project后,发现有了GlideApp但是依然报这个错误,经过搜索发现,是kotlin不兼容GlideApp,就改为了Java,

参考链接https://stackoverflow.com/questions/46638056/how-to-use-glidemodule-on-glide-4

posted @ 2019-01-05 10:12  前线开发者Kevin  阅读(1418)  评论(0编辑  收藏  举报