【问题标题】:Android studio Gradle Unable to start the daemon processAndroid studio Gradle 无法启动守护进程
【发布时间】:2025-10-31 00:40:02
【问题描述】:

我想尝试一下android studio,但是当我创建一个项目时出现这个错误:

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 Manual chapter on the daemon at https://docs.gradle.org/6.7.1/userguide/gradle_daemon.html
Process command line: C:\Program Files\Android\Android Studio\jre\bin\java.exe --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\laszl\.gradle\wrapper\dists\gradle-6.7.1-bin\bwlcbys1h7rz3272sye1xwiv6\gradle-6.7.1\lib\gradle-launcher-6.7.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.7.1
Please read the following process output to find out more:
-----------------------
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000080000000, 268435456, 0) failed; error='The paging file is too small for this operation to complete' (DOS error/errno=1455)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 268435456 bytes for Failed to commit area from 0x0000000080000000 to 0x0000000090000000 of length 268435456.
# An error report file with more information is saved as:
# C:\Users\laszl\.gradle\daemon\6.7.1\hs_err_pid30736.log

-----------------------
Check the JVM arguments defined for the gradle process in:
 - gradle.properties in project root directory

据我所知,我需要更多内存,但我有 16gb 内存,而 android studio 已经在使用 12gb。

【问题讨论】:

    标签: android-studio gradle android-gradle-plugin build.gradle gradle-plugin


    【解决方案1】:

    JVM 使用称为heap 的东西来决定它在执行必要任务时将占用多少内存。您可以将其视为在运行时保存用户定义的数据类型的地方。它类似于 RAM,但不完全是

    两种解决方案

    1. 您可以使用基于 this gui 的方式为大型项目管理堆空间

    2. 如果您更喜欢非 gui 方式,它总是更可靠,这是我从我的一个项目中附加的一个示例 gradle.properties 文件 请注意,1024m 指定了分配给 JVM 用于堆存储的 RAM 量(1024MB)。你可以在你的情况下加倍,即2048M甚至三倍

    # Project-wide Gradle settings.
    # IDE (e.g. Android Studio) users:
    org.gradle.daemon=true
    # Gradle settings configured through the IDE *will override*
    # any settings specified in this file.
    # For more details on how to configure your build environment visit
    # http://www.gradle.org/docs/current/userguide/build_environment.html
    # Specifies the JVM arguments used for the daemon process.
    # The setting is particularly useful for tweaking memory settings.
    org.gradle.jvmargs=-Xmx7g -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    # When configured, Gradle will run in incubating parallel mode.
    # This option should only be used with decoupled projects. More details, visit
    # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    org.gradle.parallel=true
    # AndroidX package structure to make it clearer which packages are bundled with the
    # Android operating system, and which are packaged with your app's APK
    # https://developer.android.com/topic/libraries/support-library/androidx-rn
    android.useAndroidX=true
    # Automatically convert third-party libraries to use AndroidX
    android.enableJetifier=true
    

    【讨论】:

    • 我已经尝试了这两种解决方案,但直到使用了我所有的内存并给出了相同的错误。
    • 嘿@ptm.rankzy 请检查所有其他应用程序是否已关闭,因为Android Studio 不应该使用那么多RAM,肯定有其他东西在运行另外请发布C:\Users\laszl\.gradle\daemon\6.7.1\hs_err_pid30736.log 的内容。如果这些都不起作用,请检查this