系统相关
首页 > 系统相关> > android – 使用picasso从firebase存储器下载图像:内存不足异常

android – 使用picasso从firebase存储器下载图像:内存不足异常

作者:互联网

我正在开发一个Android应用程序,它需要从firebase后端下载图像,但在我的recyler视图中下载并显示5到6个图像后,会抛出内存不足异常.

我使用了图像压缩库,因为每个图像的大小接近300到400 KB.

I have added <application
android:largeHeap="true"
but still there is same issue

我的代码:

//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 one rror() {
                    Toast.makeText(c, "Problem in downloading image from server", Toast.LENGTH_SHORT).show();
                }
            });

异常快照
enter image description here

如何解决这个问题呢?

解决方法:

将其添加到您的清单文件中.内部应用标签

<application
     android:largeHeap="true"

标签:android,out-of-memory,picasso,android-recyclerview,android-bitmap
来源: https://codeday.me/bug/20190701/1350564.html