Android Canvas: drawing too large bitmap

The question:

I’m running Ubuntu 16.04. And on Android Studio when I try to run my application in the emulator I get the following error:

Process: project name here, PID: 2528
java.lang.RuntimeException: Canvas: trying to draw too large(216090000bytes) bitmap.
at android.view.DisplayListCanvas.throwIfCannotDraw(
at android.widget.ImageView.onDraw(
at android.view.View.draw(
at android.view.View.updateDisplayListIfDirty(
at android.view.View.draw(
at android.view.ViewGroup.drawChild(
at android.view.ViewGroup.dispatchDraw(
at android.view.View.updateDisplayListIfDirty(
at android.view.View.draw(
at android.view.ViewGroup.drawChild(
at android.view.ViewGroup.dispatchDraw( at

I did have to run through some hoops to get my emulator working however, needed to create a sym-link so I can run the emulator on AMD. Not sure if this is part of the problem. And for the life of me I cannot figure why it continues to do this. In my group there are others who emulate the project just fine on the same emulated phone and SDK.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Move your image in the (hi-res) drawable to drawable-xxhdpi. But in app development, you do not need to use large image. It will increase your APK file size.

Method 2

The solution is to move the image from drawable/ folder to drawable-xxhdpi/ folder, as also others have mentioned.

But it is important to also understand why this somewhat weird suggestion actually helps:

The reason is that the drawable/ folder exists from early versions of android and is equivalent to drawable-mdpi. When an image that is only in drawable/ folder is used on xxhdpi device, the potentially already big image is upscaled by a factor of 3, which can then in some cases cause the image’s memory footprint to explode.

Method 3

This solution worked for me.

Add these lines in your Manifest application tag



Method 4

I had the same problem.
If you try to upload an image that is too large on some low resolution devices, the app will collapse.
You can make several images of different sizes (hdpi, xxdpi and more) or simply use an external library to load images that solve the problem quickly and efficiently.
I used Glide library (you can use another library like Picasso).

    panel_IMG_back = (ImageView) findViewById(;

Method 5

Turns out the problem was the main image that we used on our app at the time. The actual size of the image was too large, so we compressed it. Then it worked like a charm, no loss in quality and the app ran fine on the emulator.

Method 6

This issue can be resolved by 3 methods as follows:

Method 1:
By adding image into a res/drawable-nodpi folder (By doing this it will not pre-scale your image).

Method 2:
Generate all dpi(hdpi,ldpi,mdpi,xhdpi,xxhdpi,xxxhdpi) of image and add to drawable folder. (This process will increase APK size).

Method 3:
Add image to drawable/drawable-xxhdpi folder.

All these methods are verified.

Method 7

For this error was like others said a big image(1800px X 900px) which was in drawable directory, I edited the image and reduced the size proportionally using photoshop and it worked…!!

Method 8

if you use Picasso change to Glide like this.

Remove picasso


Change Glide


More efficient Glide than Picasso draw to large bitmap

Method 9

I also had this issue when i was trying to add a splash screen to the android app through the launch_backgrgound.xml . the issue was the resolution. it was too high so the images memory footprint exploded and caused the app to crash hence the reason for this error. so just resize your image using a site called nativescript image builder so i got the ldpi,mdpi and all the rest and it worked fine for me.

Method 10

I just created directory drawable-xhdpi(You can change it according to your need) and copy pasted all the images to that directory.

Method 11

If you don’t want your image to be pre-scaled you can move it to the res/drawable-nodpi/ folder.

More info:

Method 12

This can be an issue with Glide. Use this while you are trying to load to many images and some of them are very large:

Glide.load("your image path")
                               new MultiTransformation<>(
                                       new CenterCrop(),
                                       new RoundedCorners(

Method 13

Try using an xml or a vector asset instead of a jpg or png.

The reason is quite obvious in the exception name itself i.e. the resolution of the resource is too large to render.

You can png to xml using online tools like OR add your image to drawable-xxhdpi folder.

Method 14

Solution for Picasso is add Transformation for resize image.

class ResizeTransformation(private val maxSize: Int) : Transformation {
    override fun transform(source: Bitmap?): Bitmap? {
        var result:Bitmap? = null

        if (source != null) {
            var width = source.width
            var height = source.height

            val bitmapRatio = width.toFloat() / height.toFloat()

            if (bitmapRatio > 1) {
                width = maxSize;
                height = (width / bitmapRatio).toInt()
            } else {
                height = maxSize;
                width = (height * bitmapRatio).toInt()

            result = Bitmap.createScaledBitmap(source, width, height, true)


        return result

    override fun key() = "resize()"


        .transform(ResizeTransformation(2400)) //FHD+ resolution

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment