简体   繁体   English

卡在启动 gradle 守护进程

[英]Stuck at starting gradle daemon

I am an Android Developer.我是一名安卓开发者。 Yesterday I opened my current project at Android Studio and the project could not start.昨天我在 Android Studio 中打开了我当前的项目,但该项目无法启动。

An error was shown:显示错误:

Gradle sync failed: Unable to start the daemon process.
        This problem might be caused by incorrect configuration of the daemon.
        For example, an unrecognized jvm option is used.
        Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.4/userguide/gradle_daemon.html
        Please read the following process output to find out more:
        -----------------------
        Consult IDE log for more details (Help | Show Log) (4s 245ms)
  • I already edited graddle.properties to org.gradle.jvmargs=-Xmx1024m but its still not work我已经编辑graddle.propertiesorg.gradle.jvmargs=-Xmx1024m但它仍然没有工作
  • I already reinstalled my android studio with its gradle but this bug still persists我已经用它的 gradle 重新安装了我的 android studio,但这个错误仍然存​​在
  • I already deleted .gradle folder on my computer but its still stuck我已经删除了我电脑上的.gradle文件夹,但它仍然卡住了
  • I already set build process heap size in Android studio but it still not work我已经在 Android Studio 中设置了构建进程堆大小,但它仍然无法正常工作
  • I already checked my antivirus and my firewall (even turn it off) but nothing happens我已经检查了我的防病毒软件和防火墙(甚至将其关闭)但没有任何反应

I need help here, because I can't run my project at all.我在这里需要帮助,因为我根本无法运行我的项目。

Here is the gradle log:这是gradle日志:

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Caused by: org.gradle.api.GradleException: Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at
https://docs.gradle.org/4.4/userguide/gradle_daemon.html
Please read the following process output to find out more:

and this is log from daemon log这是来自守护进程日志的日志

20:37:16.805 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding loopback multicast interface Microsoft Wi-Fi Direct Virtual Adapter-QoS Packet Scheduler-0000
20:37:16.805 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface Microsoft Wi-Fi Direct Virtual Adapter-WFP 802.3 MAC Layer LightWeight Filter-0000
20:37:16.806 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
20:37:16.808 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
20:37:16.808 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding loopback multicast interface Microsoft Wi-Fi Direct Virtual Adapter-WFP 802.3 MAC Layer LightWeight Filter-0000
20:37:16.814 [ERROR] [system.err] 
20:37:16.814 [ERROR] [system.err] FAILURE: Build failed with an exception.
20:37:16.815 [ERROR] [system.err] 
20:37:16.815 [ERROR] [system.err] * What went wrong:
20:37:16.815 [ERROR] [system.err] java.net.BindException: Address already in use: bind
20:37:16.815 [ERROR] [system.err] 
20:37:16.815 [ERROR] [system.err] * Try:
20:37:16.815 [ERROR] [system.err] 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.
20:37:16.816 [ERROR] [system.err] 
20:37:16.816 [ERROR] [system.err] * Get more help at https://help.gradle.org
Daemon vm is shutting down... The daemon has exited normally or was
terminated in response to a user interrupt.

I resolved this by turning of Hotspot on my pc.我通过在我的电脑上打开热点解决了这个问题。 Found the solution here这里找到了解决方案

启动您的本地 VPN 应用程序(例如 1.1.1.1)

  1. Check if you have something like this in any of your gradle files:检查您的任何 gradle 文件中是否有类似的内容:

     jvmArgs('someValues')
  2. Go to your project config:转到您的项目配置:

在此处输入图片说明

Go to "edit configurations".转到“编辑配置”。 Make sure you select "app".确保选择“应用程序”。

在此处输入图片说明

Check the launch flags.检查启动标志。 Delete them all >:D全部删除>:D

  1. Clean and rebuild your project清理并重建您的项目

  2. You (or a program) probably changed the jvm's default run options.您(或程序)可能更改了 jvm 的默认运行选项。 Try to change them in your JVM or reinstall java and jdk if you're desperate enough.如果您足够绝望,请尝试在您的 JVM 中更改它们或重新安装 java 和 jdk。

Let me know how it goes让我知道事情的后续

Go into your home directory and find the .gradle folder.进入您的主目录并找到.gradle文件夹。 Under that folder, there are 2 folder that I delete to remove this issue.在该文件夹下,我删除了 2 个文件夹以解决此问题。 I delete the .gradle/daemons and the .gradle/caches directory.我删除了.gradle/daemons.gradle/caches目录。 Once I deleted those 2 directories and restarted Intellij/Android Studio, gradle sync started working.一旦我删除了这 2 个目录并重新启动 Intellij/Android Studio,gradle 同步就开始工作了。

On mac/linux在 mac/linux 上

cd ~/.gradle
rm -fr caches daemon

Try to do the following thing尝试做以下事情

  1. Turn off pc hotspot关闭电脑热点
  2. Restart your system重启你的系统
  3. Invalidate cache and restart pc使缓存无效并重新启动电脑

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM