首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级到Glide 4.9.0时如何解决AbstractMethodError问题

升级到Glide 4.9.0时如何解决AbstractMethodError问题
EN

Stack Overflow用户
提问于 2019-02-22 03:53:07
回答 1查看 228关注 0票数 0

这是在库模块中使用的,因此它不应该使用生成的API

升级到Glide 4.9.0

代码语言:javascript
复制
versions.glide = "4.9.0"

implementation "com.github.bumptech.glide:glide:$versions.glide"
kapt "com.github.bumptech.glide:compiler:$versions.glide"
implementation "com.github.bumptech.glide:annotations:$versions.glide"

更新了代码,没有地方在使用GlideApp

代码语言:javascript
复制
fun ImageView.loadImg(imageUrl: String) {

// 3.8.0
//    if (!TextUtils.isEmpty(imageUrl)) {
//        Glide.clear(this)
//
//        Glide.with(context).load(imageUrl)
//                .diskCacheStrategy(DiskCacheStrategy.ALL)
//                .placeholder(ColorDrawable(Color.LTGRAY))
//                .into(this)
//    }

///
// 4.+ code
    var requestOptions : RequestOptions = RequestOptions()
        .placeholder(ColorDrawable(Color.LTGRAY))
        .diskCacheStrategy(DiskCacheStrategy.ALL)

    if (!TextUtils.isEmpty(imageUrl)) {
        Glide.with(context)
            .setDefaultRequestOptions(requestOptions)  
            .asBitmap()
            .load(imageUrl)
            .into(this)
    }
}

fun ImageView.clear() {
    Glide.with(this.context).clear(this)
}

Glide.with()上崩溃

代码语言:javascript
复制
    java.lang.AbstractMethodError: abstract method "void    com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"
    at com.bumptech.glide.Glide.initializeGlide(Glide.java:270)
    at com.bumptech.glide.Glide.initializeGlide(Glide.java:223)
    at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:184)
    at com.bumptech.glide.Glide.get(Glide.java:168)
    at com.bumptech.glide.Glide.getRetriever(Glide.java:689)
    at com.bumptech.glide.Glide.with(Glide.java:716)

如果将

代码语言:javascript
复制
@GlideModule
class DPAppGlideModule : AppGlideModule() {
    override fun isManifestParsingEnabled(): Boolean {
        return false
    }
}

它可以工作,但是因为这是一个库模块,所以它不应该有这个模块。

AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"的原因可能是什么

除了GlideApp之外,还有什么也应该避免吗?

EN

回答 1

Stack Overflow用户

发布于 2019-02-22 21:46:08

事实证明,在这个库模块中,它间接依赖于使用Glide3的人,并且具有旧的GlideModule,这不会推动Glide4所需的功能。

Glide 4的module.registerComponents(applicationContext,glide,glide.registry);有3个参数,但Glide 3只有2个

代码语言:javascript
复制
 for (com.bumptech.glide.module.GlideModule module : manifestModules) {
      module.registerComponents(applicationContext, glide, glide.registry);
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54815192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档