Java Android Studio Gradle 项目“无法启动守护进程/初始化 VM”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25009717/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 23:26:04  来源:igfitidea点击:

Android Studio Gradle project "Unable to start the daemon process /initialization of VM"

javaandroidjvmdaemonbeta

提问by AsimRazaKhan

Version of Android Studio (Beta) 0.8.4
OS version: Windows 8
Java JRE/JDK version: 1.8.0_11

Android Studio (Beta) 0.8.4
版本操作系统版本:Windows 8
Java JRE/JDK 版本:1.8.0_11

Error: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 http://gradle.org/docs/1.12/userguide/gradle_daemon.html
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1048576KB object heap
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

回答by codesequel

I had the same problem. Starting Android Studio as Administrator fixed it.

我有同样的问题。以管理员身份启动 Android Studio 修复了它。

回答by nirav kalola

I had the same issue , i just remove .gradle file and restart android studio, it automatically download latest version and it works perfect.....

我遇到了同样的问题,我只是删除了 .gradle 文件并重新启动了 android studio,它会自动下载最新版本并且完美运行.....

回答by brkeyal

I had the same issue, it was because I had an existing ".gradle" folder and then I've played with the android studio version (and also with the Java jdk version) , and I guess it messed things up.

我遇到了同样的问题,这是因为我有一个现有的“.gradle”文件夹,然后我使用了 android studio 版本(以及 Java jdk 版本),我想它把事情搞砸了。

Solution: Remove the .gradle directory (mine's location was C:\Users\UserName\.gradle), and restart android studio. It will automatically create a new one.

解决方法:删除.gradle目录(我的位置是C:\Users\UserName\.gradle),重启android studio。它会自动创建一个新的。

回答by Kiran

Try adding -Xmx512min Android Studio->Settings->Compiler->VM Optionsas in below image.

尝试添加-Xmx512mAndroid Studio->Settings->Compiler->VM Options,如下面的图像。

Reason for this issue could be:Grade's build daemon ( forked process ) is invoked with maximum Java heap size as platform defaultvalue. On a 32 bit Windows this system this could be as high as 1GB. We get this error message, if that much(default) heap size cannot be allocated to the build deamon. So use the -Xmxoption to set a lower heap size. It is not necessary to stick to -Xmx<size>with size as 512m. In my Win 32bit, 4GB RAM machine, -Xmx768mwas also good enough.

此问题的原因可能是:使用最大 Java 堆大小作为平台默认值调用 Grade 的构建守护程序(分叉进程)。在 32 位 Windows 上,此系统可能高达 1GB。如果无法将那么多(默认)堆大小分配给构建守护程序,我们会收到此错误消息。因此,使用该-Xmx选项设置较低的堆大小。没有必要坚持-Xmx<size>大小为512m。在我的 Win 32bit、4GB RAM 机器上,-Xmx768m也足够好。

enter image description here

在此处输入图片说明

回答by Giru Bhai

Do Following steps:

执行以下步骤:

  1. Start Android Studio.
  2. Close any open project.Go to File > Close Project.(Welcome window will open)
  3. Go to Configure > Settings.
  4. On Settings dialog,select Compiler (Gradle-based Android Projects)from left and set VM Options to -Xmx512m(i.e. write -Xmx512m under VM Options:) and press OK.
  1. 启动安卓工作室。
  2. 关闭任何打开的项目。转到文件 > 关闭项目。(欢迎窗口将打开)
  3. 转至配置 > 设置。
  4. 在 Settings 对话框中,从左侧选择Compiler (Gradle-based Android Projects)并将 VM Options 设置为-Xmx512m(即在 VM Options: 下写 -Xmx512m),然后按 OK。

Where to put it

把它放在哪里

回答by Sandeep Ingale

Different solutions may work

不同的解决方案可能有效

  1. Delete .gradlefolder from c:\users\username\.gradle

  2. File> Settings. On Settings dialog, select Compiler (Gradle-based Android Projects)from left and set VM Options to -Xmx512m(i.e. write -Xmx512munder VM Options:) and press OK.

  3. Close multiple applications running on your machine and clear memory space and try again

  1. .gradle从中删除文件夹c:\users\username\.gradle

  2. File> Settings. 在“设置”对话框中,Compiler (Gradle-based Android Projects)从左侧选择并将 VM 选项设置为-Xmx512m(即-Xmx512m在 VM 选项下写:),然后按OK

  3. 关闭机器上运行的多个应用程序并清除内存空间并重试

回答by Trevor

I had the same problem, what i found was that Android Developer tools doesn't work well with JDK 8. I deleted my current JDK 8 and and installed JDK 7 and worked just like that no increase of heap memory or delete of .gradle folder.

我遇到了同样的问题,我发现 Android 开发人员工具不能与 JDK 8 配合使用。我删除了当前的 JDK 8 并安装了 JDK 7,并且没有增加堆内存或删除 .gradle 文件夹.

回答by Sanjeev Kumar

try to adding -Xmx512m in Android Studio->Settings->Compiler->VM Options , it's working thanks..

尝试在 Android Studio->Settings->Compiler->VM Options 中添加 -Xmx512m ,它正在工作,谢谢..

回答by Vishal Patel

  • Start Android Studio.
  • Close any open project.Go to File > Close Project.(Welcome window will open)
  • Go to Configure > Settings.
  • On Settings dialog,select Compiler (Gradle-based Android Projects) from left and set VM Options to -Xmx512m(i.e. write -Xmx512m under VM Options:) and press OK.
  • 启动安卓工作室。
  • 关闭任何打开的项目。转到文件 > 关闭项目。(欢迎窗口将打开)
  • 转至配置 > 设置。
  • 在 Settings 对话框中,从左侧选择 Compiler (Gradle-based Android Projects) 并将 VM Options 设置为 -Xmx512m(即在 VM Options 下写 -Xmx512m :),然后按 OK。

It mostly works for that initilize vm problem.

它主要适用于初始化虚拟机问题。

回答by Shriram Panchal

The Solution Worked:

解决方案有效:

    1.Open the projectsgradle.properties file in android studio
    1.在android studio中打开项目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.关闭并重新打开项目