每当我尝试使用"flutter run -v"运行Flutter应用程序时,我会遇到以下错误。如果我不使用终端而是直接点击运行按钮,则gradle任务一直在运行,什么也没有发生。
我尝试过:
Flutter运行命令: "flutter run -v"
Flutter doctor命令:
*构建APK的Flutter命令:"flutter build apk -v"
我尝试过:
- 更改gradle.properties中的语句:org.gradle.jvmargs=-Xmx1536m => org.gradle.jvmargs:-Xmx1024m
- 删除".gradle"文件
- 重启笔记本电脑
Flutter运行命令: "flutter run -v"
![Error in terminal](https://istack.dev59.com/dSlLJ.webp)
![flutter doctor](https://istack.dev59.com/spntz.webp)
[ +95 ms] executing: [C:\Flutter\flutter/] git -c log.showSignature=false log -n 1
--pretty=format:%H
[ +73 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ ] 4d7946a68d26794349189cf21b3f68cc6fe61dcb
[ +1 ms] executing: [C:\Flutter\flutter/] git tag --points-at
4d7946a68d26794349189cf21b3f68cc6fe61dcb
[ +93 ms] Exit code 0 from: git tag --points-at 4d7946a68d26794349189cf21b3f68cc6fe61dcb
[ ] 2.0.3
[ +45 ms] executing: [C:\Flutter\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +32 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [C:\Flutter\flutter/] git ls-remote --get-url origin
[ +30 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +82 ms] executing: [C:\Flutter\flutter/] git rev-parse --abbrev-ref HEAD
[ +27 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] stable
[ +85 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +59 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ +4 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +48 ms] Skipping pub get: version match.
[ +133 ms] Generating
C:\Users\Salma\Desktop\Grad\flutter_app\android\app\src\main\java\io\flutter\plugins\GeneratedPlugin
Registrant.java
[ +396 ms] Building without sound null safety
[ +1 ms] For more information see https://dart.dev/null-safety/unsound-null-safety
[ +25 ms] Running Gradle task 'assembleRelease'...
[ +8 ms] Using gradle from C:\Users\Salma\Desktop\Grad\flutter_app\android\gradlew.bat.
[ +5 ms] C:\Users\Salma\Desktop\Grad\flutter_app\android\gradlew.bat mode: 33279 rwxrwxrwx.
[ +10 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +187 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +2 ms] openjdk version "1.8.0_242-release"
OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
OpenJDK 64-Bit Server VM (build 25.242-b01, mixed mode)
[ +3 ms] executing: [C:\Users\Salma\Desktop\Grad\flutter_app\android/]
C:\Users\Salma\Desktop\Grad\flutter_app\android\gradlew.bat -Pverbose=true
-Ptarget-platform=android-arm,android-arm64,android-x64 -Ptarget=lib\main.dart
-Ptrack-widget-creation=true -Ptree-shake-icons=true assembleRelease
[+2795 ms] Starting a Gradle Daemon, 100 busy Daemons could not be reused, use --status for details
[+2481 ms] Starting a Gradle Daemon, 101 busy Daemons could not be reused, use --status for details
[+2502 ms] Starting a Gradle Daemon, 102 busy Daemons could not be reused, use --status for details
[ +23 ms] FAILURE: Build failed with an exception.
[ +4 ms] * What went wrong:
[ +2 ms] Unable to start the daemon process.
[ +1 ms] This problem might be caused by incorrect configuration of the daemon.
[ +1 ms] For example, an unrecognized jvm option is used.
[ +1 ms] Please refer to the User Manual chapter on the daemon at
https://docs.gradle.org/6.7/userguide/gradle_daemon.html
[ +1 ms] Process command line: C:\Program Files\Android\Android Studio\jre\bin\java.exe -Xmx1024m
-Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -cp
C:\Users\Salma\.gradle\wrapper\dists\gradle-6.7-all\cuy9mc7upwgwgeb72wkcrupxe\gradle-6.7\lib\gradle-
launcher-6.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.7
[ +1 ms] Please read the following process output to find out more:
[ +1 ms] -----------------------
[ ] Error occurred during initialization of VM
[ ] Could not reserve enough space for object heap
[ ] * 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.
[ +1 ms] * Get more help at https://help.gradle.org
[ +30 ms] Running Gradle task 'assembleRelease'... (completed in 8.1s)
[ +8 ms] "flutter apk" took 8,820ms.
[ +8 ms] Gradle task assembleRelease failed with exit code 1
[ +3 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 buildGradleApp (package:flutter_tools/src/android/gradle.dart:411:7)
<asynchronous suspension>
#2 _AndroidBuilderImpl.buildApk
(package:flutter_tools/src/android/android_builder.dart:101:7)
<asynchronous suspension>
#3 BuildApkCommand.runCommand
(package:flutter_tools/src/commands/build_apk.dart:103:5)
<asynchronous suspension>
#4 FlutterCommand.verifyThenRunCommand
(package:flutter_tools/src/runner/flutter_command.dart:1157:12)
<asynchronous suspension>
#5 FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:1009:27)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#8 CommandRunner.runCommand (package:args/command_runner.dart:197:13)
<asynchronous suspension>
#9 FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:278:9)
<asynchronous suspension>
#10 AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#11 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#12 FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:234:5)
<asynchronous suspension>
#13 run.<anonymous closure>.<anonymous closure>
(package:flutter_tools/runner.dart:64:9)
<asynchronous suspension>
#14 run.<anonymous closure> (package:flutter_tools/runner.dart:62:12)
<asynchronous suspension>
#15 AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#16 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#17 runInContext (package:flutter_tools/src/context_runner.dart:73:10)
<asynchronous suspension>
#18 main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>
[ +117 ms] ensureAnalyticsSent: 113ms
[ +4 ms] Running shutdown hooks
[ +1 ms] Shutdown hooks complete
[ +1 ms] exiting with code 1