0

In library module to upgrade to Glide 4.9.0.

    api "com.github.bumptech.glide:glide:4.9.0"
    api "com.github.bumptech.glide:annotations:4.9.0"
    annotationProcessor "com.github.bumptech.glide:compiler:4.9.0" 

and having a kotlin extension

fun ImageView.loadImg(imageUrl: String) {
    // 4.+ code
    var requestOptions : RequestOptions = RequestOptions()
            .placeholder(ColorDrawable(Color.LTGRAY))
            .diskCacheStrategy(DiskCacheStrategy.ALL)

    if (!TextUtils.isEmpty(imageUrl)) {
        Glide.with(context)
                .setDefaultRequestOptions(requestOptions)  // or use .apply(requestOptions) but after the .load()
                .asBitmap()
                .load(imageUrl)
                .into(this)
    }
}


but it crashes

    java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"
            at com.bumptech.glide.Glide.initializeGlide(Glide.java:270)
            at com.bumptech.glide.Glide.initializeGlide(Glide.java:223)
            at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:184)
            at com.bumptech.glide.Glide.get(Glide.java:168)
            at com.bumptech.glide.Glide.getRetriever(Glide.java:689)
            at com.bumptech.glide.Glide.with(Glide.java:716)
            at com.common.extentions.ExtensionsKt.loadImg(Extensions.kt:44)

After adding

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

to the library module does not help, or adding it to hosting app only does not work either, but after adding it to both the library module and the hosting app the crash goes away.

according to documentation https://bumptech.github.io/glide/doc/generatedapi.html, isnt it that it not supposed to have this class defined in the library module?

anyone has same experience?

  * For now the API is only generated when a properly annotated AppGlideModule is found.
  * There can only be one AppGlideModule per application.
  * As a result it’s not possible to generate the API for a library without precluding any application
  * that uses the library from using the generated API.
lannyf
  • 9,865
  • 12
  • 70
  • 152

1 Answers1

0

Resolved, it has missed

api "com.github.bumptech.glide:annotations:$versions.glide"

in the application side (not sure why adding single one in the module did not work and why with both it worked, maybe didnt do clear/rebuild after change?)

lannyf
  • 9,865
  • 12
  • 70
  • 152