皮卡索:HTTP协议方案的请求类型未被识别。

7

我正在同步加载图片,以便在图片加载完成后显示通知。

bitmap = picasso.load(imageUrl).get();

它之前运行良好,但今天出现了异常:

Fatal Exception: java.lang.IllegalStateException: Unrecognized type of request: Request{
http://www.fulbori.com/mp/resources/image/19/17/e.jpg}
       at com.squareup.picasso.BitmapHunter$2.load(BitmapHunter.java:66)
       at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:206)
       at com.squareup.picasso.RequestCreator.get(RequestCreator.java:396)
       at com.jumbotail.app.utils.JtImageLoader.loadImageSync(JtImageLoader.java:397)
       at com.jumbotail.app.notifs.JumboGcmIntentService.readInboundIntent(JumboGcmIntentService.java:213)
       at com.jumbotail.app.notifs.JumboGcmIntentService.buildNotification(JumboGcmIntentService.java:273)
       at com.jumbotail.app.notifs.JumboGcmIntentService.onHandleIntent(JumboGcmIntentService.java:49)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:174)
       at android.os.HandlerThread.run(HandlerThread.java:60)

我知道当没有请求处理程序可以处理请求时,Picasso会抛出此错误。

根据请求的Uri方案(即http),canHandleRequest(Request data)方法应该返回NetworkRequestHandler中的true

但是所有的请求处理程序都返回了false,包括NetworkRequestHandler。因此,Picasso返回了ERRORING_HANDLER,导致异常:IllegalStateException("Unrecognized type of request: " + request)

这个异常还有其他解释吗?

编辑:我还在 Picasso 中提出了 一个问题


你用的是哪个操作系统版本? - TooCool
@Abdellah,几乎所有的操作系统版本。无论哪个设备收到通知。 - Rohit Arya
我不理解Android API 23。 - TooCool
这个异常只是一次。再也没有发生过。 - Rohit Arya
2个回答

14

我遇到了这个错误,是因为我得到的URL不是一个处理程序可以使用的有效URL,就像错误信息中提到的那样。 特别地,该URL字符串在“http”之前有空格,例如:

" http://example.com/image.jpg"

所以,在使用Picasso加载之前,我只需要对URL字符串调用trim(),然后就可以正常工作了!


1
非常感谢。我花了令人沮丧的30分钟来解决这个问题。 - Surya Teja Karra

0

如果你传递给 Picasso 的路径缺少主机名和方案,你也可以得到这个 :-)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接