问题描述
我已经阅读了很多关于此的其他帖子,并且我已经阅读了 Bumptech 上的解释.但是有些东西仍然没有引起我的注意.我有以下代码:
I've read lots of other posts on this, and I've read the explanation on Bumptech. But something's still not clicking with me. I've got the following code:
if (image != null) {
GlideApp
.with(this)
.load(imageUrl)
.centerCrop()
.transition(withCrossFade())
.into(eventImageView);
}
返回上述错误:无法解析GlideApp"中的with"方法.
Which returns the error above: Cannot Resolve Method 'with' in 'GlideApp'.
我遵循了这个问题中的第一个答案:
I followed the first answer in this question:
Glide 显示错误:无法找到 GeneratedAppGlideModule
...但它似乎没有改变任何东西:
...but it doesn't seem to change anything:
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public class GlideApp extends AppGlideModule {
}
最后是我的应用 build.gradle:
lastly my app build.gradle:
implementation ("com.github.bumptech.glide:glide:4.11.0") {
exclude group: "com.android.support"
}
annotationProcessor 'androidx.annotation:annotation:1.1.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation ("com.github.bumptech.glide:glide:4.11.0@aar") {
transitive = true
}
不明白为什么Glide突然变得这么复杂...
Don't understand why Glide suddenly became so complicated...
推荐答案
根据最新说明您实际上不需要从问题中的链接中执行任何操作.您只需使用滑行"即可像往常一样,您不必使用GLideApp".
According to the latest instructions you don't actually need to do ANY of the stuff from the link in the question. You just use "Glide" as normal and you don't have to use "GLideApp".
repositories {
google()
jcenter()
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
}
看起来您也不需要设置自定义类或类似的东西.
It also doesn't look like you need to setup a custom class or anything like that.
所以我恢复了我的旧代码:
So I reverted to my old code:
Glide
.with(this)
.load(imageUrl)
.centerCrop()
.transition(withCrossFade())
.into(eventImageView);
}
这篇关于Android Glide“无法解析GlideApp中的'with'方法"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!