Tag Archives: java.lang.RuntimeException: Canvas: trying to draw too large(203212800bytes) bitmap.

java.lang.RuntimeException: Canvas: trying to draw too large(203212800bytes) bitmap.

Front end developers must read! Starting from scratch, teach you to build a low code website platform in stages>>>

https://www.cnblogs.com/spring87/p/7645625.html

Today, my master found a problem: after changing the pictures on the login page, some mobile phones will flash back when the version is updated. After borrowing a Samsung mobile phone, check the problem and report the following error:

java.lang.RuntimeException: Canvas: trying to draw too large(203212800bytes) bitmap.

one

java.lang.RuntimeException: Canvas: trying to draw too large(203212800bytes) bitmap.

Exception cause analysis: the memory needed to draw bitmap in canvas is too large. If it is oom, it will crash directly

Cause 1: the picture is too big, modify the size of the picture can solve

Cause 2: the location of the pictures is unreasonable. If there are only mipmap – * DPI folders, no drawable – * DPI corresponding folder, and only the default drawable folder, put the pictures in the drawable folder

If your device needs resources under drawable xxhdpi, you just need to move the image from drawable to drawable xxhdpi

Or create a new drawable nodpi folder and move the image resources to the drawable nodpi folder

In this case, the Android device will automatically enlarge n * n the image resources under drawable by default, regenerate a bitmap, and then load it, and then oom and crash will appear

the background image 400k of the login page given by UI was put into the drawable MDPI file without thinking about it at that time. Later, my master, Baidu, searched the blog above and revised the question. It is hereby recorded