简体   繁体   English

Flutter build apk 不起作用并显示 Gradle 任务 assembleRelease 失败,退出代码为 1

[英]Flutter build apk doesn't work and shows Gradle task assembleRelease failed with exit code 1

This is the error I get when building the app:这是我在构建应用程序时遇到的错误:

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...                                              0.5s
Resolving dependencies...                                           2.0s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                      79.9s
Gradle task assembleRelease failed with exit code 1

This is the output of flutter run -v command: https://controlc.com/3bc5e348这是 flutter run -v 命令的输出: https ://controlc.com/3bc5e348

Thanks in advance.提前致谢。

The error clearly gives you two options to build your APK.该错误清楚地为您提供了两种构建 APK 的选项。 If you're trying to upload it to the Play store then creating an app bundle is probably the best option.如果您尝试将其上传到 Play 商店,那么创建应用程序包可能是最佳选择。 Just generate app bundle as instructed in the error:只需按照错误中的指示生成应用程序包:

flutter build appbundle --target-platform android-arm,android-arm64

This will create.aab file in your release folder - <app dir>/build/app/outputs/bundle/release/app.aab这将在您的发布文件夹中创建.aab 文件 - <app dir>/build/app/outputs/bundle/release/app.aab

You should then be able to upload this aab file to Play store.然后您应该能够将此 aab 文件上传到 Play 商店。

The second option in the error message above will generate two APKs (one for 32-bit and one for 64-bit).上面错误消息中的第二个选项将生成两个 APK(一个用于 32 位,一个用于 64 位)。

More about this - Flutter site有关此的更多信息 - Flutter 网站

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 密钥库密码不正确/Gradle 任务 assembleRelease 失败,退出代码为 1 - keystore password was incorrect/Gradle task assembleRelease failed with exit code 1 完成错误:Gradle 任务 assembleRelease 失败,退出代码为 1 - Finished with error: Gradle task assembleRelease failed with exit code 1 Flutter:Gradle 任务 assembleDebug 失败,退出代码为 1 - Flutter: Gradle task assembleDebug failed with exit code 1 FLUTTER、Gradle 任务 assembleDebug 失败,退出代码为 1 - FLUTTER, Gradle task assembleDebug failed with exit code 1 Flutter Gradle 任务 assembleDebug 失败,退出代码为 1 - Flutter Gradle task assembleDebug failed with exit code 1 Gradle组装发行版不适用于ProGuard - Gradle assembleRelease doesn't work with ProGuard Gradle 任务 assembleDebug 在颤振升级中失败,退出代码为 1 - Gradle task assembleDebug failed with exit code 1 in flutter upgrade Flutter 错误:异常:Gradle 任务 assembleDebug 失败,退出代码为 1 - Flutter error: Exception: Gradle task assembleDebug failed with exit code 1 Flutter 错误 - Gradle 任务 assembleDebug 失败,退出代码为 -1 - Flutter error - Gradle task assembleDebug failed with exit code -1 Flutter Android - Gradle 任务捆绑发布失败,退出代码为 1 - Flutter Android - Gradle task bundleRelease failed with exit code 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM