使用 Picasso 加载图像 url 时出现问题

Problems with loading image url with Picasso

我正在使用 Picasso 从某个 url 加载图像,但出现此错误:

Failed to create image decoder with message 'unimplemented'

这是我的适配器 class :

class CountriesAdapter(var countriesList: ArrayList<Country>) :
    RecyclerView.Adapter<CountriesAdapter.CountriesViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CountriesViewHolder =
        CountriesViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.single_item_country, parent, false))


    override fun onBindViewHolder(holder: CountriesViewHolder, position: Int) {
        holder.bind(countriesList[position])
    }

    override fun getItemCount(): Int = countriesList.size


    class CountriesViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        fun bind(country: Country) = with(itemView) {
            itemView.tvCountryName.text = country.name
            Picasso.get().load(country.flagUrl).fit().placeholder(R.drawable.ic_asr_sun).into(itemView.ivCountryFlag)
        }

    }
}

我用 Glide 测试了相同的用例,但仍然不起作用,所以我假设我做错了什么。

编辑 url 是正确的

根据 this link 此处,在我记录 Picasso 错误后,它是:

W/System.err: java.io.IOException: Failed to decode stream.

此处无法解决此问题。正如讨论所说:

This error occurs when Android is unable to decode your image. There's nothing Picasso can do to correct this. Consider using another image format or re-encoding your image.