Using glide inside my library project

70 views
Skip to first unread message

Dinesh Kumar

unread,
Jul 21, 2023, 4:56:45 AM7/21/23
to Glide
When i try to integrate glide inside my android library project i'm getting the below error.

  java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/Glide;

Dependency i used:
implementation 'com.github.bumptech.glide:glide:4.12.0'


Any solution to make it work in android library independently, Please advise.

Róbert Papp (TWiStErRob)

unread,
Jul 21, 2023, 5:01:36 AM7/21/23
to Glide
Try to look lower in the stack trace, the exception might have a cause.
If there's no stack, then use --stacktrace Gradle CLI parameter.
In Android Studio you can add Gradle parameters at File | Settings | Build, Execution, Deployment | Gradle-Android Compiler.

Also make sure that R8 is not removing in some way.

Dinesh Kumar

unread,
Jul 21, 2023, 6:08:13 AM7/21/23
to Glide
To give more context, Actually glide dependency is getting synced, but when i try to access it i'm getting this error attaching stacktrace here.. 

    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.Glide" on path: DexPathList[[zip file "/data/app/io.inai.android_sample-2W5xOC6rfIpBQ6as8d5O0Q==/base.apk"],nativeLibraryDirectories=[/data/app/io.inai.android_sample-2W5xOC6rfIpBQ6as8d5O0Q==/lib/arm64, /system/lib64, /system/product/lib64]]
                                                                                                     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
                                                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                                         
my question is why its showing Didn't find class "com.bumptech.glide.Glide" ? 

while i try the same dependency and code snippet in android application project its working. Why its not working for android library project?

Róbert Papp (TWiStErRob)

unread,
Jul 21, 2023, 6:15:33 AM7/21/23
to Glide
Android libraries cannot be deployed onto the device, so they must be packaged into an app (APK).
When you declare an implementation dependency in a library module (or AAR) the dependencies work as they do in Java libraries: implementation is an implementation detail and api is published. That said implementation gets onto the runtime classpath (which is the configuration that gets packaged into the APK). I'm not sure why your dependency would disappear when using the library. Try to add the same dependency manually in the app as well to see if it works. If it does, then you can start investigating why it wasn't propagated from the library. You can use `gradlew dependencies` and `gradlew dependencyInsight` to see what's happening. Also you can open the APK in Android Studio's APK Analyzer to see if the class actually exists in one of the dex files.

Dinesh Kumar

unread,
Jul 21, 2023, 8:05:29 AM7/21/23
to Glide
if i add the dependency in sample application gradle, then its showing in the apk analyzer. But if i add it in the library module gradle its not working.. 
But i need this glide to work independently in my android library(aar) because, my SDK will be consumed by other 3rd party apps. 
Is there any solution to make glide work in SDK independently..?

Reply all
Reply to author
Forward
0 new messages