Flutter 任务“:app:mergeReleaseResources”执行失败

问题描述 投票:0回答:3

发生多个任务操作失败: 执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 时发生故障 > Android资源编译失败 AAPT: D:\Flutter Projects\Areading-master ndroid pp\src\main es\mipmap-hdpi\ic_launcher.png:错误:无法读取 PNG 签名:文件不以 PNG 签名开头。 D:\Flutter Projects\Areading-master ndroid pp\src\main es\mipmap-hdpi\ic_launcher.png:错误:文件无法编译。

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
        D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: error: file failed to compile.


   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
        D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: error: file failed to compile.


   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
        D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: error: file failed to compile.


   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
        D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: error: file failed to compile.

当我尝试通过此命令构建项目时发生此错误

flutter build apk --split-per-abi
我不知道那是什么? 请帮忙

java android flutter dart flutter-dependencies
3个回答
13
投票

构建器优化应用程序中的图像,在本例中为 png 图像。这是为了减小apk的大小。对于您的情况,它无法这样做。要在不进行优化的情况下运行,您可以将以下内容放入您的 build.gradle

android {
buildTypes {
    release {
        crunchPngs false // or true
    }
  }
}

2
投票

我将 res/drawable 中的 .png 文件更改为 .jpg,它对我有用


0
投票

在 buildtypes 版本中添加“crunchPngs false”解决了我的问题

© www.soinside.com 2019 - 2024. All rights reserved.