使用Picasso“收到带有0内容长度标题的响应”错误

时间:2014-09-23 21:26:03

标签: android picasso

这是我的代码:

for(int x=0; x < selEvent.photoThumbURLs.size(); x++) {
    ImageView iv = new ImageView(EventViewActivity.this);
    iv.setPadding(paddingDp*5,paddingDp,paddingDp*5,paddingDp);
    iv.setBackgroundColor(Color.rgb(255, 10, 10));    //temp
    iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
    iv.setMaxHeight(400);
    iv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    iv.setAdjustViewBounds(true);
    llImagesContainer.addView(iv);

    Picasso picasso = new Picasso.Builder(EventViewActivity.this).listener(new Picasso.Listener() {
        @Override
        public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
            exception.printStackTrace();
            Log.i("ERROR", exception.getMessage());
            Toast.makeText(getBaseContext(), exception.getMessage(), Toast.LENGTH_LONG).show();
        }
    }).build();

    picasso.with(EventViewActivity.this).setLoggingEnabled(true);
    picasso.with(EventViewActivity.this).setIndicatorsEnabled(true);

    picasso.load(selEvent.photoThumbURLs.get(x)).resize(500,500).error(R.drawable.ic_launcher).into(iv);

}

和日志

09-23 17:18:33.975  16180-16180/com.cavedgeeks.barbadostennis D/Picasso? Main        created      [R6] Request{http://[[SITE]].com/BBT/uploads/322f6253-e018-40d9-9c02-ad8ac15a9e66/thumb_photo-0-vLTRb.jpg}
09-23 17:18:33.985  16180-16483/com.cavedgeeks.barbadostennis D/Picasso? Hunter      executing    [R6]+8ms
09-23 17:18:33.985  16180-16447/com.cavedgeeks.barbadostennis D/Picasso? Dispatcher  enqueued     [R6]+7ms
09-23 17:18:34.505  16180-16447/com.cavedgeeks.barbadostennis D/Picasso? Dispatcher  retrying     [R6]+532ms
09-23 17:18:34.515  16180-16460/com.cavedgeeks.barbadostennis D/Picasso? Hunter      executing    [R6]+532ms
09-23 17:18:35.016  16180-16447/com.cavedgeeks.barbadostennis D/Picasso? Dispatcher  retrying     [R6]+1043ms
09-23 17:18:35.016  16180-16462/com.cavedgeeks.barbadostennis D/Picasso? Hunter      executing    [R6]+1043ms
09-23 17:18:35.526  16180-16447/com.cavedgeeks.barbadostennis D/Picasso? Dispatcher  batched      [R6]+1559ms for error (will replay)
09-23 17:18:35.726  16180-16180/com.cavedgeeks.barbadostennis W/System.err? java.io.IOException: Received response with 0 content-length header.
09-23 17:18:35.736  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at com.squareup.picasso.NetworkBitmapHunter.decode(NetworkBitmapHunter.java:66)
09-23 17:18:35.736  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:144)
09-23 17:18:35.736  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:101)
09-23 17:18:35.746  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
09-23 17:18:35.746  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-23 17:18:35.746  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-23 17:18:35.757  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-23 17:18:35.757  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at java.lang.Thread.run(Thread.java:841)
09-23 17:18:35.757  16180-16180/com.cavedgeeks.barbadostennis W/System.err? at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394)
09-23 17:18:35.757  16180-16180/com.cavedgeeks.barbadostennis I/ERROR? Received response with 0 content-length header.
09-23 17:18:35.777  16180-16447/com.cavedgeeks.barbadostennis D/Picasso? Dispatcher  delivered    [R6]+1800ms
09-23 17:18:35.787  16180-16180/com.cavedgeeks.barbadostennis D/Picasso? Main        errored      [R6]+1819ms

似乎只在尝试从缓存加载时才提供问题。 任何可能的解决方案或有用的建议/建议?

我尝试使用okhttp与picasso作为解决方法(就像在stackoverflow上找到的其他地方一样,但是即使它是okhttp 2.0.0,仍然会发送错误的类路径问题!

1 个答案:

答案 0 :(得分:1)

我刚切换到Ion无法找到解决毕加索问题的方法。