Open aicareles opened 5 years ago
java.lang.NoSuchMethodError: No virtual method placeholder(I)Lcom/bumptech/glide/request/RequestOptions; in class Lcom/bumptech/glide/request/RequestOptions; or its super classes (declaration of 'com.bumptech.glide.request.RequestOptions' appears in /data/app/com.example.keli-h0Lm38NUdlZHvovbP2fMmQ==/base.apk) at cn.bingoogolapple.photopicker.imageloader.BGAGlideImageLoader.display(BGAGlideImageLoader.java:47) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:76) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:83) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:87) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:91) at cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout$PhotoAdapter.fillData(BGANinePhotoLayout.java:238) at cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout$PhotoAdapter.fillData(BGANinePhotoLayout.java:223)
作者您好,最近在使用您的图片选择库时,由于项目中用了新版本的glide4.9.0,导致了这个问题,请问可否升级您的开源库兼容新版本glide
作者已经在Readme
中已经写了兼容Glide3
的方式,其实一样的,你只需要继承BGAImageLoader
然后自己实现对应函数,再在初始化的地方设置BGAImage.setImageLoader
即可
/**
* 选择照片的bga图片库需要的imageLoader,因为它的glide版本为4.5,而4.9新版会不兼容
*/
class FixedGlideImageLoader : BGAImageLoader() {
override fun display(imageView: ImageView?, path: String?, loadingResId: Int, failResId: Int, width: Int, height: Int, delegate: BGAImageLoader.DisplayDelegate?) {
if (imageView == null) return
val finalPath = getPath(path)
val activity = getActivity(imageView)
val options = RequestOptions().placeholder(loadingResId).error(failResId).override(width, height).dontAnimate()
Glide.with(activity)
.load(finalPath)
.apply(options)
.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(@Nullable e: GlideException?
, model: Any
, target: Target<Drawable>
, isFirstResource: Boolean): Boolean {
return false
}
override fun onResourceReady(resource: Drawable, model: Any
, target: Target<Drawable>
, dataSource: DataSource
, isFirstResource: Boolean): Boolean {
delegate?.onSuccess(imageView, finalPath)
return false
}
})
.into(imageView)
}
override fun download(path: String?, delegate: DownloadDelegate?) {
val finalPath = getPath(path)
Glide.with(BGABaseAdapterUtil.getApp())
.asBitmap()
.load(finalPath)
.into(object : CustomTarget<Bitmap>() {
override fun onLoadCleared(placeholder: Drawable?) {
//do nothing
}
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
delegate?.onSuccess(finalPath, resource)
}
override fun onLoadFailed(@Nullable errorDrawable: Drawable?) {
delegate?.onFailed(finalPath)
}
})
}
override fun pause(activity: Activity?) {
if (activity != null) {
Glide.with(activity).pauseRequests()
}
}
override fun resume(activity: Activity?) {
if (activity != null) {
Glide.with(activity).resumeRequestsRecursive()
}
}
}
是的,当时就是看了那个 解决的,多谢
java.lang.NoSuchMethodError: No virtual method placeholder(I)Lcom/bumptech/glide/request/RequestOptions; in class Lcom/bumptech/glide/request/RequestOptions; or its super classes (declaration of 'com.bumptech.glide.request.RequestOptions' appears in /data/app/com.example.keli-h0Lm38NUdlZHvovbP2fMmQ==/base.apk) at cn.bingoogolapple.photopicker.imageloader.BGAGlideImageLoader.display(BGAGlideImageLoader.java:47) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:76) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:83) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:87) at cn.bingoogolapple.photopicker.imageloader.BGAImage.display(BGAImage.java:91) at cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout$PhotoAdapter.fillData(BGANinePhotoLayout.java:238) at cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout$PhotoAdapter.fillData(BGANinePhotoLayout.java:223)
作者您好,最近在使用您的图片选择库时,由于项目中用了新版本的glide4.9.0,导致了这个问题,请问可否升级您的开源库兼容新版本glide