我无法弄清楚为什么会出现以下错误:
E/UncaughtException: java.lang.NoClassDefFoundError: 解析失败:Lcom/somecompany/someapp/common/glide/GlideWrapper$loadCircularProfileImg$1$1; 在 com.somecompany.someapp.common.glide.GlideWrapper.loadCircularProfileImg(GlideWrapper.kt:31) 在 com.somecompany.someapp.main.MainActivity.showSideBarProfPhoto(MainActivity.kt:179) 在 com.somecompany.someapp.main.MainActivity .onCreate(MainActivity.kt:115) 在 android.app.Activity.performCreate(Activity.java:
使用代码:
fun loadCircularProfileImg(ctx: Context, user: User?, targetImageView: ImageView) {
user?.let {
// With let getting a NoClassDefFoundError error
GlideApp.with(ctx)
.asBitmap()
.load(FirebaseStorage.getInstance().reference.child(it.profImgUrl))
.into(object : BitmapImageViewTarget(targetImageView) {
override fun setResource(resource: Bitmap?) {
// Will add code here
}
})
}
}
但不是:
fun loadCircularProfileImg(ctx: Context, user: User?, targetImageView: ImageView) {
if (user != null) { // With this the code works
GlideApp.with(ctx)
.asBitmap()
.load(FirebaseStorage.getInstance().reference.child(user.profImgUrl))
.into(object : BitmapImageViewTarget(targetImageView) {
override fun setResource(resource: Bitmap?) {
// Will add code here
}
})
}
}