Loading image from firebase storage using picasso: memory exception

I am working on an Android application that should load images from the firebase backend, but after loading and displaying from 5 to 6 images, a memory exception is thrown in my recyler view.

I used the image compression library, due to which the size of each image is from 300 to 400 KB.

I added <application android:largeHeap="true", but still have the same problem

My code is:

//Retriving image from picasso
            Picasso.Builder builder = new Picasso.Builder(c);
            builder.listener(new Picasso.Listener() {
                @Override
                public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
                    Toast.makeText(c,exception.getMessage(),Toast.LENGTH_LONG).show();
                }
            });
            Picasso pic = builder.build();
            pic.load(currentPost.getDownloadlinkDB()).into(((MyViewHolder_Image) holder).imageView, new Callback() {
                @Override
                public void onSuccess() {

                }

                @Override
                public void onError() {
                    Toast.makeText(c, "Problem in downloading image from server", Toast.LENGTH_SHORT).show();
                }
            });

Exception snapshot enter image description here

How to solve this problem?

+4
source share
1 answer

Add this to your manifest file. Internal application tag

<application
     android:largeHeap="true"
+2

Source: https://habr.com/ru/post/1674061/


All Articles