[英]Picasso on Android does not load this image Uri
这张图片Uri: http : //d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg未在毕加索加载
它在浏览器上加载良好。
Picasso.with(this)
.load(Uri.parse(
"http://d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg"))
.fit()
.error(android.R.drawable.stat_notify_error)
.centerCrop()
.into(iv, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError() {
Log.d("error", "error");
}
});
设定:
OkHttpClient client = new OkHttpClient();
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
client.interceptors().add(logging);
Picasso.setSingletonInstance(new Picasso.Builder(this).downloader(new OkHttpDownloader(client))
.memoryCache(new LruCache(50 * 1024 * 1024))
.indicatorsEnabled(true)
.loggingEnabled(true)
.build());
使用的库
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.squareup.okhttp:okhttp:2.7.0'
compile 'com.squareup.okhttp:logging-interceptor:2.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
整个资源可以在这里看到(仅一项活动)
也添加了成功日志。 但是我得到了错误方法的回调。
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: --> GET http://d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg HTTP/1.1
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: Cache-Control: max-stale=2147483647, only-if-cached
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: --> END GET
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: <-- HTTP/1.1 504 Unsatisfiable Request (only-if-cached) (0ms)
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: <-- END HTTP (0-byte body)
从此处升级到Picasso版本2.6.0-SNAPSHOT可以解决此问题。 https://oss.sonatype.org/content/repositories/snapshots/com/squareup/picasso/picasso/2.6.0-SNAPSHOT/
您需要在清单文件中配置INTERNET
权限。 没有它,您的应用程序(因而也就是毕加索)将无法访问互联网。
例:
<manifest package="in.curium.picassotest.picassotest"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name=".App"
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.