GlideApp not found using LibraryGlideModule (Glide 4)

泄露秘密 提交于 2019-11-27 19:36:45

问题


Using Glide 4 in combination with okhttp3 and a LibraryGlideModule:

@GlideModule
public final class MyGlideModule extends LibraryGlideModule {

    @Override
    public void registerComponents(Context context, Glide glide, Registry registry) {
        registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
    }
}

The GlideApp class is not generated when building, while it is when I extend AppGlideModule. Using LibraryGlideModule there seems to be no generated Glide classes at all.

What am I doing wrong?


回答1:


In your Android Studio: - Click menu Build - Clik Make Module

And GlideApp Class will automatically generated




回答2:


  1. You need to create a new class MyAppGlideModule and extend AppGlideModule to it.

Refer the code below:

import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
// new since Glide v4
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {
    // leave empty for now
}
  1. Build -> Make Project



回答3:


If GlideAPP can't be generated

Attention: annotationProcessor com.github.bumptech.glide:compiler:4.9.0

Must be with AppGlideModule Implementation class In the same module




回答4:


You cannot use generated API (i.e. the GlideApp class) while using LibraryGlideModule. Reference: http://bumptech.github.io/glide/doc/generatedapi.html#availability

"The generated API is only available for applications for now." (i.e. only available for AppGlideModule)



来源:https://stackoverflow.com/questions/45960073/glideapp-not-found-using-libraryglidemodule-glide-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!