This is the only answer the solved my this issue for me - https://stackoverflow.com/a/46638213
This configuration worked for me -
- In app module gradle -
implementation "com.github.bumptech.glide:glide:${glide_version}"
implementation "com.github.bumptech.glide:okhttp3-integration:${glide_version}"
kapt "com.github.bumptech.glide:compiler:${glide_version}"
- In app proguard -
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep class com.bumptech.glide.GeneratedAppGlideModuleImpl
- My Custom Glide module class -
package com.github.iamutkarshtiwari.glidedemoapp;
import android.content.Context;
import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.AppGlideModule;
import java.io.InputStream;
import okhttp3.OkHttpClient;
@GlideModule
public final class OkHttp3GlideModule extends AppGlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
super.applyOptions(context, builder);
}
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
OkHttpClient client = new OkHttpClient.Builder()
.build();
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client);
glide.getRegistry().replace(GlideUrl.class, InputStream.class, factory);
}
}
- Glide 4.0 need not have "GlideModule" declaration in AndroidMinifest.xml
- You need to
Make project
in order to generateGlideApp
class