Reputation: 928
I'm trying to get a drawable from a url with Glide but it keeps failing.
I'm using Glide version 4.12.0 which is the latest: implementation 'com.github.bumptech.glide:glide:4.12.0'
I've already tried using RequestListener but it kept failing, therefore I am looking for an alternative.
comment.imageURL?.takeIf { loadImage }?.let { imageUrl ->
Glide.with(context).load(comment.imageURL).into(object : CustomTarget<Drawable>() {
override fun onLoadFailed(errorDrawable: Drawable?) {
// code
}
override fun onResourceReady(resource: Drawable,
transition: Transition<in Drawable>?) {
// code
}
override fun onLoadCleared(placeholder: Drawable?) {
// code
}
})
}
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/galdahan/podsync/Models/Comment$Companion$transform$5$1;
at com.galdahan.podsync.Models.Comment$Companion.transform(Comment.kt:71)
at com.galdahan.podsync.Models.Comment$Companion.transform$default(Comment.kt:47)
at com.galdahan.podsync.FIREBASE_API.Post_CommnentsApi$observeComments$1.onDataChange(Post_CommnentsApi.kt:75)
at com.google.firebase.database.Query$1.onDataChange(com.google.firebase:firebase-database@@19.2.0:179)
at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@19.2.0:75)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@19.2.0:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@19.2.0:55)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.galdahan.podsync.Models.Comment$Companion$transform$5$1" on path: DexPathList[[dex file "/data/data/com.galdahan.podsync/code_cache/.overlay/base.apk/classes6.dex", zip file "/data/app/~~u26Hv32StBK7WzdCxOOa-A==/com.galdahan.podsync-gxbX5HkcbxEI2A_Cnrev2A==/base.apk"],nativeLibraryDirectories=[/data/app/~~u26Hv32StBK7WzdCxOOa-A==/com.galdahan.podsync-gxbX5HkcbxEI2A_Cnrev2A==/lib/x86_64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.galdahan.podsync.Models.Comment$Companion.transform(Comment.kt:71)
at com.galdahan.podsync.Models.Comment$Companion.transform$default(Comment.kt:47)
at com.galdahan.podsync.FIREBASE_API.Post_CommnentsApi$observeComments$1.onDataChange(Post_CommnentsApi.kt:75)
at com.google.firebase.database.Query$1.onDataChange(com.google.firebase:firebase-database@@19.2.0:179)
at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@19.2.0:75)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@19.2.0:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@19.2.0:55)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Upvotes: 0
Views: 778
Reputation: 330
From the stacktrace, here are some few things that can be observed.
Here's what you can do to single out your problem:
At this point, your app should not be crashing. Proceed;
If you are listening to data changes inside onDataChange
, you can use a try/catch to get the value from the snapshot and log it before conversion(as I had mentioned earlier).
Once you are sure of the fields in the expected object, update your model accordingly, then access the imageUrl
property and pass it over to glide.
In summary, glide is not the cause of this crash, instead, it's how your data is being mapped to your local models.
Upvotes: 1