运行“flutter run”时,无法连接到Gradle守护程序,

7y4bm7vi  于 2023-11-21  发布在  Flutter
关注(0)|答案(7)|浏览(124)

我试着在新创建的flutter项目上运行'flutter run',但它卡在Resolving dependencies中,并在日志中出现以下错误。

Launching lib/main.dart on ASUS X00DDA in debug mode...
Initializing gradle...                                       1.2s
Resolving dependencies...
* Error running Gradle:
Exit code 1 from: C:\Users\username\Desktop\Project\myprojectr\android\gradlew.bat app:properties:
Starting a Gradle Daemon, 14 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Could not connect to the Gradle daemon.
Daemon uid: 6a5529f2-392b-4727-b66f-78a2fab605bf with diagnostics:
Daemon pid: 14840
  log file: C:\Users\arjay24\.gradle\daemon\4.1\daemon-14840.out.log
----- Last  20 lines from daemon log file - daemon-14840.out.log -----
15:00:39.882 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
15:00:39.888 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:00:39.889 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
15:00:39.890 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:00:39.891 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:00:39.891 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
15:00:39.892 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:00:39.893 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:00:39.893 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
15:00:39.893 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:00:49.885 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
15:00:49.885 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:00:49.886 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
15:00:49.886 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:00:49.887 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:00:49.887 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
15:00:49.888 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:00:49.889 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:00:49.889 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] The file lock is held by a different Gradle process (pid: 13900, operation: ). Will attempt to ping owner at port 61789
15:00:49.889 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] The file lock is held by a different Gradle process. I was unable to read on which port the owner listens for lock access requests.
----- End of the daemon log -----

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

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

Please review your Gradle project setup in the android/ folder.

字符串
这很奇怪,因为前几天它工作得很好,我没有改变或安装任何东西。

kse8i1jr

kse8i1jr1#

我通过断开VPN解决了这个问题。看起来很奇怪,但它起作用了:-)

czfnxgou

czfnxgou2#

该问题似乎不是由Flutter引起的。检查日志,由于“文件锁由不同的Gradle进程持有”,示例无法连接到Gradle守护程序。如果您仍然存在此问题,请尝试removing the lock files in the Gradle cache并再次尝试运行应用程序?

atmip9wb

atmip9wb3#

我也有不正确的路径distributionUrl在你的_root_directory/android/gradle/wrapper/gradle-wrapper.properties
在更正路径后,它工作了:distributionUrl=https:services.gradle.org/distributions/gradle-6.7-all.zip

iibxawm4

iibxawm44#

我得到了一个想法从@F.Tepel回答,卸载我的防病毒软件后,我的问题得到了解决.

y0u0uwnf

y0u0uwnf5#

我通常通过跑步来解决这个问题。

./gradlew --stop

字符串

ojsjcaue

ojsjcaue6#

有趣的是,对我来说,问题是没有互联网连接。我最近修改了一些Gradle配置,显然它需要从互联网下载一些东西。

yruzcnhs

yruzcnhs7#

我也遇到了同样的问题。我通过改变your_root_directory/android/gradle/wrapper/gradle-wrapper.properties文件中的distributionUrl来升级gradle解决了这个问题。
您可以参考此处获取升级gradle的说明

相关问题