简体   繁体   中英

How to give default values in gradle.properties in android studio

Each time when I start new project in android studio, I have to change the contents of gradle.properties from org.gradle.jvmargs=-Xmx1536m to org.gradle.jvmargs=-Xmx1024m to avoid gradle loading errors and restart the project which takes more time. Is there any way that I can add the default values to this gradle.properties which will be applied to all the projects I create?

To change the maximum heap size, for Android STudio and not for a single project follow these steps:

  1. Click Help > Edit Custom VM Options to open your studio.vmoptions file.
  2. Add a line to the studio.vmoptions file to set maximum heap size using the syntax -XmxheapSize. The size you choose should be based on the size of your project and the available RAM on your machine. As a baseline, if you have more than 4GB of RAM and a medium-sized project, you should set the maximum heap size to 2GB or more. The following line sets the maximum heap size to 2GB: -Xmx2g
  3. Save your changes to the studio.vmoptions file, and restart Android Studio for your changes to take effect.
  4. To confirm your new maximum heap size, open the command line, and type the following command:

     jps -lvm 

    You will see a list of the instrumented JVMs running on your machine, including the full package name for each and the arguments passed in. Locate the item corresponding to your instance of Android Studio. It should end with -Didea.paths.selector=AndroidStudio[Version]. You should see two arguments beginning with -Xmx for this JVM, one with the default value of 1280mb, and one with your new value, as shown in figure 在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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