Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picasso does not load the image nor does it log #1931

Open
sriramr98 opened this issue Jun 24, 2018 · 21 comments
Open

Picasso does not load the image nor does it log #1931

sriramr98 opened this issue Jun 24, 2018 · 21 comments

Comments

@sriramr98
Copy link

I am supplying picasso through Koin (DI).

This is my Picasso configuration

fun getPicasso(context: Context, downloader: OkHttp3Downloader): Picasso {
    return Picasso.Builder(context)
            .downloader(downloader)
            .indicatorsEnabled(true)
            .loggingEnabled(true)
            .build()

}

This is theOkHttp3 and OkHttp3Downloader

fun getPicassoDownloader(okHttpClient: OkHttpClient): OkHttp3Downloader {
    return OkHttp3Downloader(okHttpClient)
}
fun getOkHttpInstance(headerInterceptor: HeaderInterceptor, loggingInterceptor: HttpLoggingInterceptor, cache: Cache): OkHttpClient {
    return OkHttpClient.Builder()
            .addInterceptor(headerInterceptor)
            .addInterceptor(loggingInterceptor)
            .cache(cache)
            .build()
}

This OkHttp3 is a singleton used across every entity that requires it such as Retrofit, Picasso.

I then load the image like this in a recycler view

picasso.load(image.urls?.regular)
                    .fit()
                    .centerCrop()
                    .into(itemView.item_image)

I have logged the URL's and verified that the URL's are working
But I see no image in the imageView nor do I see any logs as I've set logging interceptor to be true.

I also tried commenting out the OkHttpDownloader instance in picasso so that I use the default configuration. But that doesn't work either.

Picasso Version : 2.71828
OkHttp3Downloader Version: 1.1.0
OkHttp3 Version : 3.10.0

Android Device : One Plus 6
Android Version : 8.1.0
Android OS : Oxygen OS 5.1.8

@JakeWharton
Copy link
Member

JakeWharton commented Jun 24, 2018 via email

@sriramr98
Copy link
Author

No. I verified by logging the URL's separately in onBindViewHolder. I also opened them. They work perfectly.

@JakeWharton
Copy link
Member

JakeWharton commented Jun 24, 2018 via email

@sriramr98
Copy link
Author

I just commented out the dependency, removed the comments and ran the build. Everything works fine now. I don't know why it didnt work for the past hour. Thanks for the immediate reply anyway.

@lemberh
Copy link

lemberh commented Jun 25, 2018

I have similar problem
I have updated from 2.5.2 to 2.71828
And changed Picasso.with(context) to Picasso.get()
On previous version everything worked, URL are valid

Here is the log:
with transformation

06-25 19:57:38.494 15724-15724/com.oitchau.debug D/Picasso: Main created [R1] Request{http://res.cloudinary.com/rnaz/image/upload/c_fill,g_face:center,h_100,q_auto:best,w_100/v1/samples/people/smiling-man.jpg CropCircleTransformation()}
06-25 19:57:38.497 15724-15801/com.oitchau.debug D/Picasso: Hunter joined [R1]+1ms to [R0]+13s, [R1]+2ms

without

06-25 20:00:08.758 16068-16068/com.oitchau.debug D/Picasso: Main created [R0] Request{http://res.cloudinary.com/rnaz/image/upload/c_fill,g_face:center,h_100,q_auto:best,w_100/v1/samples/people/smiling-man.jpg}
06-25 20:00:08.775 16068-16133/com.oitchau.debug D/Picasso: Dispatcher enqueued [R0]+16ms
06-25 20:00:08.789 16068-16179/com.oitchau.debug D/Picasso: Hunter executing [R0]+31ms

@sriramr98
Copy link
Author

Yeah but I didn't use with () anywhere. I supplied the Picasso instance as above using DI. All I did was clean and re build the project and it started working

@FantasyLand17
Copy link

I can confirm that this issue is still present after updating to Picasso 2.7. I have narrowed it down to this:

This does NOT work

@Provides @Singleton
 Picasso providePicasso(Application app, OkHttpClient client) {
     return new Picasso.Builder(app)
             .downloader(new OkHttp3Downloader(client))
             .listener(new Picasso.Listener() {
                 @Override
                 public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
                     Timber.e(exception, "Failed to load image: %s", uri);
                 }
             })
             .build();
 }

This works ( Notice missing OkHttp3Downloader ):

@Provides @Singleton
 Picasso providePicasso(Application app, OkHttpClient client) {
     return new Picasso.Builder(app)
             .listener(new Picasso.Listener() {
                 @Override
                 public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
                     Timber.e(exception, "Failed to load image: %s", uri);
                 }
             })
             .build();
 }

I am not sure how to debug this but what appears to be happening is that something is going on with OkHttp3Downloader and PIcasso 2.7

@ssawchenko
Copy link

Did you find a solution to this? I have also just done an update to 2.7 and I am no longer getting images downloading. I see nothing being reported in the console either...

@ATOM49
Copy link

ATOM49 commented Oct 4, 2018

@FantasyLand17 gave me a hint
I removed this form my code and it's working fine.

OkHttp3Downloader okHttp3Downloader = new OkHttp3Downloader(context, Integer.MAX_VALUE);
picassoBuilder.downloader(okHttp3Downloader);

@kwiky
Copy link

kwiky commented Oct 11, 2018

I confirm that no image is shown when we use OkHttp3Downloader with Picasso 2.7
Version 2.7 works fine without setting a downloader

@tiwiz
Copy link

tiwiz commented Oct 25, 2018

EDIT: it looks like there is a reason for that #31

@JakeWharton maybe this issue could be closed?


OLD:
The same happened to me, using OkHttp3Downloader 1.1.0 with Picasso 2.7 results in no images showing with the following code:

Picasso picasso = new Picasso.Builder(this)
                .downloader(new OkHttp3Downloader(okHttpClient))
                .build();
Picasso.setSingletonInstance(picasso);

but it works as expected if the downloader is removed.

@NightlyNexus
Copy link
Contributor

uh, i am curious about why a custom downloader wasn't working in Picasso e, in case you find out. Jake's library should have just worked the same as the builtin downloader in Picasso e.

@babul01pro
Copy link

babul01pro commented Oct 30, 2018

Be oversure image URL path with https protocol, hopefully, it will be work!!!

Example:

https://bangladhol.com/book_th/C29B5E81.jpg

instead of

http://bangladhol.com/book_th/C29B5E81.jpg

@ssawchenko
Copy link

Following up: for me the issue was setting a cache on the OkHttpClient. This appeared to be caching 404 results, so if I failed to get an image for some reason, I was never able to download the image. In my case this was actually happening very often as we were requesting URLs before they were fully ready.

Removing the caching on OkHttpClient fixed my issue, and since Picasso is already caching for us, we didn't really need it on the http client anyways (that I am aware of).

@Kolyall
Copy link

Kolyall commented Nov 9, 2018

Here is working project with the issue.
https://github.com/Kolyall/Picasso271828
To fix it use com.squareup.picasso.OkHttp3Downloader instead of com.jakewharton.picasso.OkHttp3Downloader

@mattdrzazga
Copy link

Can confirm, replacing Jake's Downloader with Squareup OkHttp3Downloader fixed this issue.
(Using picassoVersion = '2.71828')

@chhattsolutions
Copy link

so anyone found any solution?? i'm currently using 2.5.2

@MohHamoud
Copy link

MohHamoud commented Jul 24, 2019

@chhattsolutions did you try using com.squareup.picasso.OkHttp3Downloader instead of com.jakewharton.picasso.OkHttp3Downloader as @Kolyall suggested?
As it worked for me

@AhmadSadiq0
Copy link

I was facing the same error, I resized the same image and uploaded to the firebase then load its url using picasso and this time it worked totally file images was loaded successfully.
Note same image was not showing nor there were any logs before it was resized.

@TianchenWei
Copy link

I met the "same" problem and finally found out the reason: my system time was incorrect, accidentally set system time to future. That's not Picasso's problem. :P

@zf0x00
Copy link

zf0x00 commented Sep 13, 2020

I also have the same problem when I changed with() to get() and as @ATOM49 says I remove the two lines from my API call all working good now thanks for the tip

Removed Lines:
OkHttp3Downloader okHttp3Downloader = new OkHttp3Downloader(okHttpClient);
.downloader(okHttp3Downloader)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet