square / picasso

A powerful image downloading and caching library for Android
https://square.github.io/picasso/
Apache License 2.0
18.71k stars 3.97k forks source link

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

Open sriramr98 opened 6 years ago

sriramr98 commented 6 years ago

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 commented 6 years ago

I suspect the URL is null. Otherwise there would be logs.

On Sun, Jun 24, 2018, 10:33 AM Sriram R notifications@github.com wrote:

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/picasso/issues/1931, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEbBJBQdjOIomgCmLWSRAGcMgZMh0ks5t_6MsgaJpZM4U1LID .

sriramr98 commented 6 years ago

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

JakeWharton commented 6 years ago

There's not enough information to diagnose a problem here then. The sample app works. Can you provide a sample which doesn't so we can debug?

On Sun, Jun 24, 2018, 10:42 AM Sriram R notifications@github.com wrote:

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

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/square/picasso/issues/1931#issuecomment-399761613, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEaoHTveJ-eMDycCsS8_WY7PSan-Qks5t_6U8gaJpZM4U1LID .

sriramr98 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

chhattsolutions commented 5 years ago

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

MohHamoud commented 5 years ago

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

AhmadSadiq0 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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)