android - 从 Flutter 项目构建 APK 时出错
问题描述
当我尝试从我的颤振项目构建 APK 时遇到了一个问题。我使用 appicon.co 创建应用程序图标。
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle... 1.4s
Resolving dependencies... 6.4s
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
Output: D:\projects\e-cal app\ECAL appication\ecal\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
Command: C:\Users\DELL\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\dc6524cdbb29b6d93306387944c512dd\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
D:\projects\e-cal app\ECAL appication\ecal\build\app\intermediates\res\merged\release \
D:\projects\e-cal app\ECAL appication\ecal\android\app\src\main\res\mipmap-hdpi\ic_launcher.png
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 76.4s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
如何解决这个问题?有人可以帮忙吗。
解决方案
我不确定,但是在构建时,您应该尝试构建应用程序包,因为它不会占用太多空间,并且会使人们更有可能获得您的应用程序。
推荐阅读
- reactjs - 测试要使用 jest 调用的组件的 onClose 事件
- php - 尝试运行任务时,发送图像,收到错误代码 = 13“查询已取消”
- json - 使用转义变量在 jq 中提取值
- createprocess - Eiffel:如何创建和使用 UTIL 类,或“从类中调用静态方法”
- perl - 如何在 perl 中使用 Date::Calc 获取上个月的日期?
- python - 绘制人口和组的分布
- google-cloud-functions - 如何访问 Google Cloud Function 执行指标?
- unity3d - Unity SteamVR - 强制脱离手
- sql-server - 当我查看表设计和脚本表与 information_schema 和 sys.columns 时,为什么我会得到不同的列比例?
- javascript - 无法将 SocketIO 服务器从 docker 容器连接到外部