【问题标题】:Unable to display images Firebase Kotlin getting - java.lang.IllegalArgumentException: Path must not be empty无法显示 Firebase Kotlin 获取的图像 - java.lang.IllegalArgumentException:路径不能为空
【发布时间】:2020-01-21 12:26:31
【问题描述】:

几天前,代码工作正常,图像显示正常,但是当我在一周后尝试进行测试时,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)
    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
    }

}

通过删除 Picasso,我可以在 Logcat 中获取链接,但是当我启用时,我会得到上面的链接。什么可能导致问题。

添加毕加索的Logcat

2020-01-21 17:50:13.439 6157-6157/com.example.project D/NewMessageActivity: Profilepic link: https://url
2020-01-21 17:50:13.452 6157-6157/com.example.project D/NewMessageActivity: Profilepic link: https://url
2020-01-21 17:50:13.461 6157-6157/com.example.project D/NewMessageActivity: Profilepic link: https://url
2020-01-21 17:50:13.471 6157-6157/com.luvpi.luvproject D/NewMessageActivity: Profilepic link: https://url

【问题讨论】:

  • userProfilePic 的值是多少?你确定不是空字符串吗?
  • 我只是简单地定义了 FindViewById 即 CircleImageView,相同的代码用于正常工作,所以我没有做任何更改
  • 请回答我第一条评论中的问题,以便我或其他开发人员可以帮助您。
  • 不是空字符串
  • 你能添加一个日志语句并提供给我们确切的值吗?

标签: android firebase kotlin picasso


【解决方案1】:

您的网址无效。日志告诉你:

Profilepic link: https://url

https://url”不是有效的 URL,不会加载图像。检查您的源数据。

【讨论】:

    【解决方案2】:

    只需替换参数,我就可以加载图片。

    Picasso.get()
            .load(user.thumb_image)
            .into(viewHolder.itemView.imageview_new_message)
    

    我不知道为什么这行得通,而不是定义 val。任何人都可以解释他们两个之间的区别以及为什么这是一个工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-04
      • 2020-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-14
      相关资源
      最近更新 更多