Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin/kapt - Glide: Failed to find GeneratedAppGlideModule #2817

Closed
Mathbl opened this issue Jan 16, 2018 · 6 comments
Closed

Kotlin/kapt - Glide: Failed to find GeneratedAppGlideModule #2817

Mathbl opened this issue Jan 16, 2018 · 6 comments

Comments

@Mathbl
Copy link

Mathbl commented Jan 16, 2018

Glide Version: 4.5.0

Integration libraries: okhttp3-integration

Device/Android Version: doesn't seem device related. The warning shows on emulators and every test devices I have.

Issue details / Repro steps / Use case background:
I followed the setup instructions. Glide is working as expected in my app, but i'm getting this warning in logcat, which shouldn't be there since my setup seems correct.

Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored

I'm using kotlin. kapt plugin is applied at the top of my build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

and I also have this

implementation 'com.github.bumptech.glide:glide:4.5.0'
kapt 'com.github.bumptech.glide:compiler:4.5.0'
implementation "com.github.bumptech.glide:okhttp3-integration:4.5.0"

I have created a class extending AppGlideModule

@GlideModule
class MyAppGlideModule : AppGlideModule() {
    override fun applyOptions(context: Context, builder: GlideBuilder) {
        super.applyOptions(context, builder)
        if (BuildConfig.DEBUG) {
            builder.setLogLevel(Log.VERBOSE)
        }
    }
}

kapt seems to generate the GlideApp, GlideOptions, GlideRequest, GlideRequests, GeneratedAppGlideModuleImpl and GeneratedRequestManagerFactory classes correctly. I can see them.

@sjudd
Copy link
Collaborator

sjudd commented Jan 16, 2018

Sounds like another duplicate of #1939. Are you able to use the generated API? If so, does the app crash?

@sjudd sjudd added the question label Jan 16, 2018
@Mathbl
Copy link
Author

Mathbl commented Jan 16, 2018

From what i've read in #1939, people were missing includes or didn't follow the setup instructions.

Like I said, the classes seem to be generated correctly by kapt cause I can see them and browse them. I'm also using GlideApp APIs throughout the app without problems.

And, the code that triggers the warning is looking for a class that seems to be generated correctly:

try {
      Class<GeneratedAppGlideModule> clazz =
          (Class<GeneratedAppGlideModule>)
              Class.forName("com.bumptech.glide.GeneratedAppGlideModuleImpl");
      result = clazz.getDeclaredConstructor().newInstance();
    } catch (ClassNotFoundException e) {
      if (Log.isLoggable(TAG, Log.WARN)) {
        Log.w(TAG, "Failed to find GeneratedAppGlideModule. You should include an"
            + " annotationProcessor compile dependency on com.github.bumptech.glide:compiler"
            + " in your application and a @GlideModule annotated AppGlideModule implementation or"
            + " LibraryGlideModules will be silently ignored");
      }
}

GeneratedAppGlideModuleImpl:
img

@sjudd
Copy link
Collaborator

sjudd commented Jan 16, 2018

If you're able to reproduce this in a sample app, I'm happy to take a look.

Otherwise, if you can use the generated API in your app and it doesn't crash, it's unlikely that the method in question is actually failing. There's some casting that will throw if that happens. Can you provide your Glide load line?

@Mathbl
Copy link
Author

Mathbl commented Jan 16, 2018

I just tried to put on a sample app that reproduces the issue, and after adding one library at a time to reproduce my actual app configuration, I found out the culprit: Intercom library (https://github.com/intercom/intercom-android).

I know they use a repackaged version of Glide in their library, I'll check their repo to see if I can find something.

Thanks. Feel free to close the issue, because I presume it is more an issue with intercom!

@sjudd
Copy link
Collaborator

sjudd commented Jan 16, 2018

Awesome thanks for investigating. Let me know if you find anything. We may be able to make the error message more useful, like include the package name of the class we tried to load, which would make repackaging at least clearer (if they change the class package names).

@stale
Copy link

stale bot commented Jan 23, 2018

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

@stale stale bot added the stale label Jan 23, 2018
@stale stale bot closed this as completed Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants