Flutter 设置安卓启动页报错 java.lang.RuntimeException: Canvas: trying to draw too large(106,975,232 bytes) bi


设置安卓启动页报错

  • 首先设置安卓启动页

  • 在android/app/src/main/AndroidManifest.xml中添加这一行

  • 然后找到android/app/src/main/res/drawable/launch_background.xml

  • 添加代码

     
    
        
     
  • 如果在这里不行就将代码放在同级的另一个drawable-v21文件夹中,然后将图片放在drawable文件夹中

  • 结果运行之后发现报错图片太大,在网上压缩图片从2.9MB到400K都还是报错,最后在stackflow上找到解决办法

https://stackoverflow.com/questions/39111248/canvas-trying-to-draw-too-large-bitmap-when-android-n-display-size-set-larger/44072270#44072270?newreg=b5b40430a64f4ad9b56afac076c58228

Move your image in the drawable to mipmap-xxhdpi.Your image is in bitmap format so you should put your image in mipmap folder,then it will work

  • 将图片从drawable中移动到mipmap-xxxhdpi中

  • 然后更改drawable或者drawable-21文件夹中launch_background.xml的代码为新的地址


    

  • 就好啦