since glide 4.0.0 has changed a bit.
First of all, GlideModule deprecated, and you need to use AppGlideModule if you are developing an application and LibraryGlideModule to develop a library. you need to use @GlideModule over your custom AppGlideModule class.
Secondly, there is no register() method in Glide .
and finally, okhttp3 will use the builder.
for applications, it will be as follows:
@GlideModule private class CustomGlideModule extends AppGlideModule { @Override public void registerComponents(Context context, Glide glide, Registry registry) { OkHttpClient client = new OkHttpClient.Builder() .readTimeout(15, TimeUnit.SECONDS) .connectTimeout(15, TimeUnit.SECONDS) .build(); OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client); glide.getRegistry().replace(GlideUrl.class, InputStream.class, factory); } }
you will need to have all this dependency with the exact versions in your gradle application:
compile "com.squareup.okhttp3:okhttp:3.8.1" compile 'com.github.bumptech.glide:glide:4.0.0' compile ('com.github.bumptech.glide:okhttp3-integration:4.0.0'){ exclude group: 'glide-parent' }
Amir ziarati
source share