knockmark10
knockmark10

Reputation: 113

Convert View to Bitmap (OutOfMemoryException)

I have a Bitmap created from a View with the kotlin extesion drawToBitmamp(). It works fine in most cases, but in low end devices, it throws an OutOfMemoryException.

I've been doing research about how to handle Bitmaps efficiently, but I found nothing when it comes to bitmaps generated from View's. Does anyone know how to avoid that exception while handling it better?

Any suggestion is welcome.

Upvotes: 0

Views: 48

Answers (1)

gpuser
gpuser

Reputation: 1183

Try this way to add

android:largeHeap="true" in application tag in manifest

and also add below line

dexOptions{ javaMaxHeapSize "4g" }

in app level gradle or jvmargs=-Xmx2048M

Hope it may help you

Upvotes: 1

Related Questions