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

设置安卓启动页报错

  • 首先设置安卓启动页

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

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

  • 然后找到android/app/src/main/res/drawable/launch_background.xml
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
  • 添加代码
<!-- You can insert your own image assets here -->
     <item>
    <!-- android:gravity="center" -->
        <bitmap
         android:src="@drawable/splash"/>
    </item> 
  • 如果在这里不行就将代码放在同级的另一个drawable-v21文件夹中,然后将图片放在drawable文件夹中

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

https://*.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

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

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

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

<item>
    <bitmap android:src="@mipmap/splash" />
</item>
  • 就好啦
上一篇:java.lang.AbstractMethodError: org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.cho


下一篇:Mendix嵌入Java代码将金钱转换为中文大写