Android 无法显示图像Firebase Kotlin getting-java.lang.IllegalArgumentException:路径不能为空
几天前,代码运行良好,图像显示正常,但当我在一周后尝试进行测试时,android studio开始显示错误Android 无法显示图像Firebase Kotlin getting-java.lang.IllegalArgumentException:路径不能为空,android,firebase,kotlin,picasso,Android,Firebase,Kotlin,Picasso,几天前,代码运行良好,图像显示正常,但当我在一周后尝试进行测试时,android studio开始显示错误 java.lang.IllegalArgumentException: Path must not be empty. at com.squareup.picasso.Picasso.load(Picasso.java:332) at com.example.project.messeges.UserItem.bind(NewMessageActivity.kt:115)
java.lang.IllegalArgumentException: Path must not be empty.
at com.squareup.picasso.Picasso.load(Picasso.java:332)
at com.example.project.messeges.UserItem.bind(NewMessageActivity.kt:115)
at com.example.project.messeges.UserItem.bind(NewMessageActivity.kt:103)
我使用的是Groupie扩展Kotlin,下面是用于完美工作的代码
class UserItem(val user: User): Item(){
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
var userProfilePicLink: String? = null
var userProfilePic = viewHolder.itemView.findViewById<CircleImageView>(R.id.imageview_new_message)
userProfilePicLink = user.thumb_image
viewHolder.itemView.username_textview_new_message.text = user.username
Picasso.get().load(userProfilePicLink).into(userProfilePic)
Log.d(TAG, "Profilepic link: $userProfilePicLink")
}
override fun getLayout(): Int {
return R.layout.user_row_new_message
}
}
您的URL无效。日志告诉您:
Profilepic link: https://url
“”不是有效的URL,不会加载图像。检查源数据。只需更换参数,我就可以加载图片
Picasso.get()
.load(user.thumb_image)
.into(viewHolder.itemView.imageview_new_message)
我不知道为什么这样做而不是定义val。有谁能解释一下两者之间的区别,以及为什么这样做是可行的用户档案PIC的值是多少?你确定它不是空字符串吗?我只是简单地定义了findViewById,它是CircleImageView,与正常工作时使用的代码相同,因此我没有做任何更改。请回答我在第一条评论中提出的问题,以便我或其他开发人员可以帮助你。它不是空字符串。你能添加一条日志语句并向我们提供准确的值吗?
Picasso.get()
.load(user.thumb_image)
.into(viewHolder.itemView.imageview_new_message)