Frank
Frank

Reputation: 12298

GlideApp not found using LibraryGlideModule (Glide 4)

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

Answers (7)

Androidz
Androidz

Reputation: 729

If you use Kotlin, try to use kapt instead of annotationProcessor.

Upvotes: 2

Reejesh PK
Reejesh PK

Reputation: 4160

Adding visual information for @Abbas answer,

If the build error stops at a position like : enter image description here

Go further on top and see this error: enter image description here

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

fahrizal89
fahrizal89

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:

  • Click on the "Build" menu
  • Click "Make Module " to generate the project-specific GlideApp Class.
  • If that doesn't work, rebuild the project using "Make Project"

Upvotes: 15

Abbas
Abbas

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

brady lee
brady lee

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

enter image description here

Upvotes: 3

Alen Lee
Alen Lee

Reputation: 2509

  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

Upvotes: 8

Rahul Gurnani
Rahul Gurnani

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

Related Questions