Flutter - FAILURE:构建失败,出现异常.- 无法启动守护进程.- Android Studio - VSCode [英] Flutter - FAILURE: Build failed with an exception. - Unable to start the daemon process. - Android Studio - VSCode

查看:91
本文介绍了Flutter - FAILURE:构建失败,出现异常.- 无法启动守护进程.- Android Studio - VSCode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试使用 flutter run -v 运行 flutter 应用程序时,我都会收到以下错误.如果我不使用终端并单击运行,则正在运行的 gradle 任务将继续运行,并且没有任何反应.

Whenever I try to run a flutter app using flutter run -v i get the below error. If i don't use the terminal and just click run the running gradle task keeps running and nothing happens.

我试过了:

  1. 已在 gradle.properties org.gradle.jvmargs=-Xmx1536m => 中更改org.gradle.jvmargs:-Xmx1024m
  2. 已删除 .gradle 文件
  3. 重置我的笔记本电脑

我能做什么?

颤动运行 -v

颤振医生

*flutter build apk -v

*flutter build apk -v

[  +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

推荐答案

问题是 OpenJDK 平台二进制打开了很多占用我内存的实例,我从这个 问题这个答案 说要关闭热点并且确实有效.此外,重新启动笔记本电脑可能适用于某些情况,但并非全部.

The problem was that OpenJDK platform binary opens many instances which eats up my memory, I found out about this problem from this question and this answer said to turn off the Hotspot and that did work. Also restarting your laptop might work for some cases but not all.

我不知道 Hotspot 是如何出现问题的,也不知道它以何种方式连接到 OpenJDK,如果有人有解释,请发表评论.

I don't know how the Hotspot is the problem or in what way is it connected to OpenJDK if anyone has an explanation please comment it.

这篇关于Flutter - FAILURE:构建失败,出现异常.- 无法启动守护进程.- Android Studio - VSCode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆