When flutter is packaged as apk, an error occurs [Process 'command 'E:\flutter\bin\flutter.bat'' finished with non-zero exit value]

1. Use flutter build apk to package. At this time, an error is reported, the content is as follows:


FAILURE: Build failed with an exception.

* Where:
Script 'E:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'E:\flutter\bin\flutter.bat'' finished with non-zero exit value 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.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 4s
Running Gradle task 'assembleRelease'...                           67.7s
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1

     At this time, the specific cause of the error cannot be found, because it is all Flutter's own error, not a problem with our code.

2. Need to use    

flutter build apk  --release -vv 

 At this time, a more detailed error will be output. The error content is as follows:

[   +2 ms] [  +16 ms] Done persisting file store
[   +1 ms] [   +9 ms] Target android_aot_release_android-arm64 failed: ProcessException: Failed to find
"E:\flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot" in the search path.
[   +2 ms]              Command: E:\flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot
[   +1 ms]            #0      LocalProcessManager.start (package:process/src/interface/local_process_manager.dart:58:7)
[   +1 ms]            #1      ErrorHandlingProcessManager.start.<anonymous closure>
(package:flutter_tools/src/base/error_handling_io.dart:664:24)
[   +1 ms]            #2      _run (package:flutter_tools/src/base/error_handling_io.dart:544:20)
[   +1 ms]            #3      ErrorHandlingProcessManager.start
(package:flutter_tools/src/base/error_handling_io.dart:663:12)
[   +4 ms]            #4      _DefaultProcessUtils.start (package:flutter_tools/src/base/process.dart:425:28)
[   +3 ms]            #5      _DefaultProcessUtils.stream (package:flutter_tools/src/base/process.dart:444:35)
[   +1 ms]            #6      GenSnapshot.run (package:flutter_tools/src/base/build.dart:75:26)
[   +1 ms]            #7      AOTSnapshotter.build (package:flutter_tools/src/base/build.dart:209:56)
[   +4 ms]            #8      AndroidAot.build (package:flutter_tools/src/build_system/targets/android.dart:247:52)
[   +4 ms]            #9      _BuildInstance._invokeInternal
(package:flutter_tools/src/build_system/build_system.dart:828:27)
[   +1 ms]            <asynchronous suspension>
[   +3 ms]            #10     Future.wait.<anonymous closure> (dart:async/future.dart)
[   +1 ms]            <asynchronous suspension>
[   +1 ms]            #11     _BuildInstance.invokeTarget
(package:flutter_tools/src/build_system/build_system.dart:766:32)

        At this time, E:\flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot is displayed. This file is not found. Go to the directory and take a look. Sure enough, it is not there. It was killed by 360, so it is restored. one time.

       Hope this helps everyone!

Guess you like

Origin blog.csdn.net/saperliu/article/details/118640681