gpt4 book ai didi

android - NoClassDefFoundError 与 Kotlin 中的 ?.let{} block

转载 作者:行者123 更新时间:2023-11-29 01:03:51 25 4
gpt4 key购买 nike

我不明白为什么会出现以下错误:

E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/somecompany/someapp/common/glide/GlideWrapper$loadCircularProfileImg$1$1; at com.somecompany.someapp.common.glide.GlideWrapper.loadCircularProfileImg(GlideWrapper.kt:31) at com.somecompany.someapp.main.MainActivity.showSideBarProfPhoto(MainActivity.kt:179) at com.somecompany.someapp.main.MainActivity.onCreate(MainActivity.kt:115) at android.app.Activity.performCreate(Activity.java:6955) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

使用代码:

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
}
})
}
}

最佳答案

当你调用 loadCircularProfileImg 时用户类被定义,我调用相同的方法并且没有得到如下所示的任何错误......

        loadCircularProfileImg(this,User(),imageview)

我在上面的代码中使用并且没有收到任何错误。

关于android - NoClassDefFoundError 与 Kotlin 中的 ?.let{} block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49080621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com