将 Glide 3.8 迁移到 4.5,applyOptions 不再执行?

Migrating Glide 3.8 to 4.5, applyOptions not executed anymore?

我刚从 Glide 3.8 迁移到 Glide 4.5

当我使用GlideModule

class ImageGlideModule : GlideModule {
    override fun registerComponents(context: Context, glide: Glide, registry: Registry) {

    }

    override fun applyOptions(context: Context, builder: GlideBuilder) {
        val detector = MainApplication.component.getPerformacneDetect()
        if (detector.isHighPerformingDevice) {
            builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888)
        } else {
            builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565)
        }
    }
}

我的清单里有

    <meta-data
        android:name="com.elyeproj.melbournemalaysianfood.ImageGlideModule"
        android:value="AppGlideModule" />

applyOptions 调用没有问题。

但是现在我更改为 AppGlideModule(版本 4.5 方法),如下所示,使用 @GlideModule 注释。

@GlideModule
class ImageGlideModule : AppGlideModule() {

    override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
        super.registerComponents(context, glide, registry)
    }

    override fun applyOptions(context: Context, builder: GlideBuilder) {
        val detector = MainApplication.component.getPerformacneDetect()
        if (detector.isHighPerformingDevice) {
            builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888)
        } else {
            builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565)
        }
    }
}

我的 applyOption 根本没有被调用。我尝试使用和不使用清单中的元数据,同样的事情发生了。我错过了什么吗?我怎样才能让我的 AppGlideModuleapplyOptions 接到电话?

已找到无法正常工作的原因。我需要为滑行添加 annotationProcessor,因为我使用的是 @GlideModule。所以在 Kotlin 中,就是 kapt

implementation 'com.github.bumptech.glide:glide:4.6.1'
kapt 'com.github.bumptech.glide:compiler:4.6.1'

还有不要忘记添加

apply plugin: 'kotlin-kapt'

在 gradle 文件的顶部