简体   繁体   English

Gradle 同步失败:无法启动守护进程

[英]Gradle sync failed: Unable to start the daemon process

I am new to Android development and Java but after successfully installing Android Studio and the JDK, managing to create my first app and test it both in the emulator and on a phone now whenever I open Android Studio I get the following Message:我是 Android 开发和 Java 的新手,但在成功安装 Android Studio 和 JDK 后,设法创建我的第一个应用程序并在模拟器和手机上测试它现在每当我打开 Android Studio 我收到以下消息:

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/3.3/userguide/gradle_daemon.html
        Please read the following process output to find out more:
        -----------------------
        Consult IDE log for more details (Help | Show Log)

I have searched this site and extensively on Google and so far all suggested solutions I have found have failed.我已经搜索了这个网站并在谷歌上进行了广泛的搜索,到目前为止,我发现的所有建议解决方案都失败了。

I am using Android Studio 2.3.3 and JDK 1.8.0_131.我正在使用 Android Studio 2.3.3 和 JDK 1.8.0_131。

So far I have tried:- Uninstalling both Android Studio and the JDK, deleting any folders left behind and then re-installing both.到目前为止,我已经尝试过:- 卸载 Android Studio 和 JDK,删除留下的所有文件夹,然后重新安装两者。

  1. Deleting the.gradle folder from C:\Users\$username$.从 C:\Users\$username$ 中删除 .gradle 文件夹。
  2. Changing the Build Process Heap Size to 1024.将构建进程堆大小更改为 1024。
  3. Invalidating all caches and restarting multiple times.使所有缓存失效并重新启动多次。
  4. Double checking and even Triple checking the paths to the JDK and Android SDK.双重检查甚至三次检查 JDK 和 Android SDK 的路径。
  5. Ensuring that I have no extra open programs/windows and background apps in case it was a memory shortage issue suggested in some posts.确保我没有额外的打开程序/窗口和后台应用程序,以防某些帖子中建议的 memory 短缺问题。

I am still at a loss as to how to fix this problem and open to any suggestions.我仍然不知道如何解决这个问题并接受任何建议。 Thank you.谢谢你。

奇怪的是,就我而言,重新启动计算机每次都可以正常工作。

Sheff Do Following steps: Sheff做以下步骤:

1.Start Android Studio. 1.启动Android Studio。

2.Close any open project.Go to File > Close 2.关闭所有打开的项目。转到文件>关闭

3.Project.(Welcome window will open) Go to Configure > Settings. 3.项目。(将打开“欢迎”窗口)转到“配置”>“设置”。

On Settings dialog,select Compiler (Gradle-based Android Projects) 在“设置”对话框上,选择“编译器”(基于Gradle的Android项目)

from left and set VM Options to -Xmx512m(ie write -Xmx512m under VM Options:) and press OK. 从左侧将VM Options设置为-Xmx512m(即,在VM Options:下写入-Xmx512m),然后按OK。

The Solution Worked for me 解决方案对我有用

1.Open the projects gradle.properties file in android studio 1.在android studio中打开project gradle.properties文件

2.Added this line at end of file org.gradle.jvmargs=-Xmx1024m & Save the file 2.将此行添加到文件org.gradle.jvmargs = -Xmx1024m的末尾并保存文件

3.Close & reopen the project 3.关闭并重新打开项目

Both method is same but you said new to Android studio so I give both suggestions..if any doubt text me 两种方法都一样,但是您是Android Studio的新手,所以我给出了两个建议。

If this affects a single project, it can be due to a missing gradle.properties or gradle-wrapper.properties file.如果这影响单个项目,则可能是由于缺少gradle.propertiesgradle-wrapper.properties文件。

Try these defaults in the project directory在项目目录中尝试这些默认值

gradle.properties

org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=false
android.nonTransitiveRClass=true
android.enableR8.fullMode=true
android.buildTypes.release.ndk.debugSymbolLevel = SYMBOL_TABLE

and

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

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

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