I want to display a random image using Unsplash website with Picasso. However the image won't display on API 17 physical tablet. It does display on API 28 emulator.
How do I display images using Picasso on API 17 devices?
Picasso version:
implementation 'com.squareup.picasso:picasso:2.71828'
load image:
private const val RAND_IMAGE_URL:String = "https://images.unsplash.com/photo-1617721042477-7c5c498e7dbf?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=800&ixlib=rb-1.2.1&q=80&w=800"
// Load the random image
val image = findViewById<ImageView>(R.id.iv_image)
Picasso.get().load(RAND_IMAGE_URL)
.error(R.drawable.ic_error_outline_72)
.into(image, object : Callback {
override fun onSuccess() {
// successfully loaded
// hide progress bar
progressBar.visibility = View.GONE
}
override fun onError(e: Exception?) {
// display error message
Log.e(TAG, "error loading image", e)
// hide progress bar
progressBar.visibility = View.GONE
}
})
The error:
com.squareup.picasso.NetworkRequestHandler$ResponseException: HTTP 504
at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:51)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:219)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:175)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:354)
I tried solutions in this link, this link, and changing URL to http, but nothing worked. I also found this post talking about some protocol change but I don't know what it means or if it's related.