类Landroid/widget/ImageView中没有字段mMaxWidth。

11

我使用UniversalImageLoader (displayImage方法)来加载图片

但它会抛出NoSuchFieldException异常:

在类Landroid/widget/ImageView中没有mMaxWidth字段; ('android.widget.ImageView'的声明出现在/system/framework/framework.jar!classes3.dex中)

如何修复?


1
请转到Glide:https://github.com/bumptech/glide - IntelliJ Amiya
2个回答

14

问题已修复,但 Gradle 版本未更新。

解决方案 1:

现在不要使用

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

或者

.jar file
你可以下载库文件的zip压缩包,手动添加为模块。 我遇到了相同的问题,但是在我的情况下这个方法有效。 如果需要更改文件,你可以查看这个commit:f6a9615 解决方案二: 你可以使用JitPack引入这个commit: 在你的build.gradle(应用层级别)文件中加入:
repositories {
    maven { url "https://jitpack.io" }
}

替换为:

implementation 'com.github.bumptech.glide:glide:4.12.0'

implementation 'com.github.nostra13:Android-Universal-Image-Loader:f6a9615868482672c3630cb7db6dcf43391e80de'

2
这个解决方案可行,与GitHub上的这个评论相同。 - John Pang

3

自2019年以来,在加载回收视图中的图像时,我一直遇到这个问题。但是现在已经正常工作了,就像预期的那样。 - MohanRaj S

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接