how to use GlideModule on Glide 4?

I recently update my app to use Glide 4, to be precise, Glide 4.2.0. gradle:

compile 'com.github.bumptech.glide:glide:4.2.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
compile ('com.github.bumptech.glide:okhttp3-integration:4.2.0'){
    exclude group: 'glide-parent'
}

in manifest:

<meta-data
            android:name="com.bei5000.debm.MyGlideModule"
            android:value="GlideModule"/>

GlideModule class:

@GlideModule
public class MyGlideModule extends AppGlideModule {

    @Override
    public void registerComponents(Context context, Glide glide, Registry registry) {
        OkHttpClient client = new OkHttpClient.Builder()
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .connectTimeout(30, TimeUnit.SECONDS)
                .build();

        OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client);

        glide.getRegistry().replace(GlideUrl.class, InputStream.class, factory);
    }
}

how I use glide inside an adapter:

        RequestOptions myOptions = new RequestOptions()
                .placeholder(R.drawable.ic_placeholder)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .dontAnimate()
                .skipMemoryCache(true)
                ;

        Glide.with(mContext)
                .load(Imageid[position])
                .apply(myOptions)
                .into(imageView);

with these code, when I run it I got error:

java.lang.RuntimeException: Expected instanceof GlideModule, but found: [my app package][email protected]
  at com.bumptech.glide.module.ManifestParser.parseModule(ManifestParser.java:81)
  at com.bumptech.glide.module.ManifestParser.parse(ManifestParser.java:43)
  at com.bumptech.glide.Glide.initializeGlide(Glide.java:193)
  at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:172)
  at com.bumptech.glide.Glide.get(Glide.java:156)
  at com.bumptech.glide.Glide.getRetriever(Glide.java:540)
  at com.bumptech.glide.Glide.with(Glide.java:566)
  at [adapter line where I implement Glide]

how can I use MyGlideModule ?

enter image description here

try this

Glide 4.0 need not have declare "GlideModule" in AndroidMinifest.xml. You just need to following steps:

  1. YourGlideModule extends AppGlideModule, you can override function applyOptions in the YourGlideModule class.
  2. You should make project in "android studio -> build -> make project", it will generate the GlideApp class.
  3. Use the GlideApp such as "GlideApp.with(this).load(imgUrl).into(glide_test_iv1)"