How to increase maximum heap size for the Gradle daemon?

前端 未结 5 1055
孤街浪徒
孤街浪徒 2021-02-20 07:41

When signin an apk, I got this message:

To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
For faster builds, increase the m         


        
相关标签:
5条回答
  • 2021-02-20 08:05

    I know you said your project doesnt have gradle.properties but you could create a global one in C:\Users\user\.gradle and add:

     org.gradle.jvmargs=-Xmx4096M
    

    And remember to run gradle --stop to kill any previous daemons.

    0 讨论(0)
  • 2021-02-20 08:11

    You can try any one of the following

    1) change the gradle.properties file and change the heap size as per your requirement.

    If org.gradle.jvmargs=-Xmx2048M is not sufficient then change to 4096 as given

    org.gradle.jvmargs=-Xmx4096M

    2)"Edit Custom VM Options" from the Help menu.

    It will open studio.vmoptions / studio64.exe.vmoptions file

    Change the content to

    -Xms128m

    -Xmx4096m

    -XX:MaxPermSize=1024m

    -XX:ReservedCodeCacheSize=200m

    -XX:+UseCompressedOops

    Save the the file and restart Android Studio.

    0 讨论(0)
  • 2021-02-20 08:13

    If you don't have gradle.properties then go to your project folder you will find gradle files there create a text file and name it as gradle.properties removing .txt and then add the below code to that file.

    # Project-wide Gradle settings.
    
    # IDE (e.g. Android Studio) users:
    # 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=-Xmx4096m
    
    # 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
    

    and save it then open your project in Android Studio and click on sync now.

    I hope it will resolve your issue, if not please let me know.

    0 讨论(0)
  • 2021-02-20 08:19

    Try this link answer

    dexOptions 
       {
           javaMaxHeapSize "4g"
       }
    ....
    ....
    ....
    
    0 讨论(0)
  • 2021-02-20 08:22

    Add following code to your build.gradle file.

     android {
         dexOptions {
         incremental true       
         javaMaxHeapSize "4g"
          }
        }
    

    Reference : Source

    0 讨论(0)
提交回复
热议问题