android - Glide 4.12.0 找不到 GeneratedAppGlideModule
问题描述
我正在使用 Glide 显示来自 firebase 存储的图像,但出现此错误:
W/Glide:未能找到 GeneratedAppGlideModule。您应该在应用程序中包含对 com.github.bumptech.glide:compiler 的 annotationProcessor 编译依赖项,并且 @GlideModule 注释的 AppGlideModule 实现或 LibraryGlideModules 将被静默忽略
我试图从Glide Failed to find GeneratedAppGlideModule和Android Glide "Cannot Resolve Method 'with' in GlideApp"中找到解决方案,但它们都不起作用。
以下是我在回收器视图适配器中的示例代码:
Glide.with(context).load(imageurl).into(viewHolder.getImageview());
我正在使用最新版本的 Glide:
实现 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
清理、重建项目和无效/重新启动对我不起作用。如果有人可以提出解决此问题的解决方案,我将不胜感激。谢谢你。
我在 build.gradle (项目)中的代码:
allprojects {
repositories {
google()
mavenCentral()
}
}
我在 build.gradle (模块)中的代码:
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
我在 proguard-rules.pro 中的代码:
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class
com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}
解决方案
根据官方文档,您必须:
粘贴到您的 Gradle 文件中
存储库 { google() mavenCentral() }
依赖项 { 实施 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' }
Proguard - 根据您的 ProGuard (DexGuard) 配置和使用情况,您可能需要在 proguard.cfg 中包含以下行
-keep public class * implements com.bumptech.glide.module.GlideModule -keep class * extends com.bumptech.glide.module.AppGlideModule { <init>(...); } -keep public enum com.bumptech.glide.load.ImageHeaderParser$** { **[] $VALUES; public *; } -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { *** rewind(); } # for DexGuard only -keepresourcexmlelements manifest/application/meta-data@value=GlideModule
推荐阅读
- matlab - 增加 parfor 循环的工作人员数量
- c++ - 如何检查提升消息队列是否存在
- java - 如何配置hibernate search 5.9工作线程池大小
- r - 计算前 6 个数据点的平均值
- javascript - 作为函数的结果增加特定元素的变量值
- excel - 选择前一个文件夹的文件夹对话框
- jmeter - 多次调用 JMeter 预处理器
- android - 如何在 firebase Live Database 中保存模型?
- graphics - Meshlab 没有可视化三角形的面,层格式错误?
- angular - @ngrx/store 不适用于 ng serve -prod