Reputation: 12298
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?
Upvotes: 6
Views: 11951
Reputation: 729
If you use Kotlin, try to use kapt
instead of annotationProcessor
.
Upvotes: 2
Reputation: 4160
Adding visual information for @Abbas answer,
If the build error stops at a position like :
Go further on top and see this error:
In My case, it pointed out a Room Db error, which when fixed, fixed this error also (GlideApp not found).
So fix the top level error first and then try running the app again.
Upvotes: 0
Reputation: 845
Glide v4 uses an annotation processor to generate an API. This allows applications to extend Glide’s API and include components provided by integration libraries.
To generate the GlideApp
api in your Android Project, do the following:
In your Android Studio:
GlideApp
Class.Upvotes: 15
Reputation: 3331
Another reason for the GlideApp
class to not generate could be other errors in the project. So, if you've added the
annotationProcessor "com.github.bumptech.glide:compiler:${rootProject.ext.glideVersion}"
dependency, and set up a class which extends AppGlideModule
and annotated properly with @GlideModule
, then make sure scroll down in the Build
View in Android Studio and make sure there are no errors other than GlideApp not found.
Upvotes: 3
Reputation: 111
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
Upvotes: 3
Reputation: 2509
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
}
Upvotes: 8
Reputation: 194
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)
Upvotes: 3