Reputation: 199
This image Uri: http://d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg does not load in Picasso
It loads fine on browser.
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");
}
});
Set up:
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 used
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'
the whole source can be seen here (Just one activity)
Added success log too. But I get a callback in error method.
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)
Upvotes: 0
Views: 1575
Reputation: 199
This gets fixed by upgrading to Picasso version 2.6.0-SNAPSHOT from here. https://oss.sonatype.org/content/repositories/snapshots/com/squareup/picasso/picasso/2.6.0-SNAPSHOT/
Upvotes: 1
Reputation: 1252
You need to configure the INTERNET
permission in your manifest file. Without it, your app (and thus picasso) cannot access internet.
Example:
<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"
...
Upvotes: 0