android-glide - 如何在库模块中使用 GlideApp 生成的 api?

标签 android-glide android-module

构建库模块。在使用库模块的示例应用程序中

@GlideModule
class DPAppGlideModule : AppGlideModule() {
    override fun isManifestParsingEnabled(): Boolean {
        return false
    }
}

并且在库模块中有:
@GlideModule
public final class LibGlideModule extends LibraryGlideModule {
}

并在库模块中使用 GlideApp 生成的 api
fun ImageView.loadImg(imageUrl: String) {
var requestOptions : RequestOptions  = RequestOptions()
requestOptions.diskCacheStrategy(DiskCacheStrategy.ALL)
if (!TextUtils.isEmpty(imageUrl)) {
    GlideApp.with(this.context)
            .setDefaultRequestOptions(requestOptions)
            .load(imageUrl)
            .into(this)
}

}

但由于这是库模块,不能对应用程序模块有体面,所以它无法编译

如何在库模块中使用 GlideApp 生成的 api?

引用 - https://bumptech.github.io/glide/doc/configuration.html

最佳答案

只需添加

annotationProcessor com.github.bumptech.glide:compiler:4.8.0
模块 gradle 文件中的依赖项。同步项目然后清理并重建它。
如果你的模块使用 kotlin.将“annotationProcessor”更改为“kapt”。
小心如果你有其他模块依赖,确保你使用正确的 GlideApp 对象。也许其他模块有它自己的 GlideApp 对象

关于android-glide - 如何在库模块中使用 GlideApp 生成的 api?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55264154/

相关文章:

android - 使用单个 NavHostFragment 导航具有多个模块的应用程序

android - 使用 Glide 在 ImageView 中显示 GIF

android - 关于 Glide 库的详细信息

android - 滑动 FileNotFoundException : No content provider when loading images from internet

java - glide 如何取消图片下载请求?

安卓导航。从嵌套图 fragment 弹出到外部 fragment

java - 如何用Glide显示不同的图像?

android - 当库模块而不是主应用程序使用动态模块时,是否有在 Play 商店中使用动态模块的示例?

android - 我需要增加库模块的版本代码吗?

模块与 flavor 之间的Android区别