这是在库模块中使用的,因此它不应该使用生成的API
升级到Glide 4.9.0
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
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()上崩溃
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)如果将
@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之外,还有什么也应该避免吗?
发布于 2019-02-22 21:46:08
事实证明,在这个库模块中,它间接依赖于使用Glide3的人,并且具有旧的GlideModule,这不会推动Glide4所需的功能。
Glide 4的module.registerComponents(applicationContext,glide,glide.registry);有3个参数,但Glide 3只有2个
for (com.bumptech.glide.module.GlideModule module : manifestModules) {
module.registerComponents(applicationContext, glide, glide.registry);
}https://stackoverflow.com/questions/54815192
复制相似问题