此图片Uri:http://d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg未在Picasso中加载
它在浏览器上加载正常。
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());
使用了libs
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)
答案 0 :(得分:1)
通过从此处升级到Picasso版本2.6.0-SNAPSHOT可以解决此问题。 https://oss.sonatype.org/content/repositories/snapshots/com/squareup/picasso/picasso/2.6.0-SNAPSHOT/
答案 1 :(得分:0)
您需要在manifest file中配置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"
...