简体   繁体   中英

Update Android Studio From Command Line

Problem

When updating Android Studio using patches, I get:

Temp. directory: C:\Users\user\AppData\Local\Temp\

java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2271)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)

from the updater.

Just a note: I am updating from 2.0 Preview 8 to 2.0 Preview 9, but I've had this issue for as long as I've used Studio, I think version 0.8 even. I'm aware I can just get a fresh copy of Android Studio, but I would prefer to download just 18 MB through the patch rather than the full 300 MB every time.

Progress

I believe I need to increase the heap size for the updater. I know I can do this through command line arguments, but I don't know where the updater is, nor how to run it.

I've tried increasing Java heap size through environment variables, but to no avail. It might not have worked on the updater somehow, so I want to try setting it directly.

Question

I'd like to know how to update with increased heap size. The file location of the updater jar would also be enough to get me started, and the full command to run would be brilliant.

I discovered that VM options can be modified for Android Studio as a whole, including the updater. http://tools.android.com/tech-docs/configuration

Create your own .properties or .vmoptions files in the following directories.

The folder name, referenced as {FOLDER_NAME} below, depends on the version of Android Studio, usually AndroidStudiox.x

  • Windows:
    • %USERPROFILE%.{FOLDER_NAME}\\studio.exe.vmoptions and/or %USERPROFILE%.{FOLDER_NAME}\\studio64.exe.vmoptions
    • %USERPROFILE%.{FOLDER_NAME}\\idea.properties
  • Mac:
    • ~/Library/Preferences/{FOLDER_NAME}/studio.vmoptions
    • ~/Library/Preferences/{FOLDER_NAME}/idea.properties
  • Linux:
    • ~/.{FOLDER_NAME}/studio.vmoptions and/or ~/.{FOLDER_NAME}/studio64.vmoptions
    • ~/.{FOLDER_NAME}/idea.properties

Increasing IDE Memory

By default, the IDE is assigned a maximum of 750 MB. If you have a large project, or if you have a lot of RAM on your system, the IDE will run better if you increase the amount of memory it is allowed to use. To do that, create your own studio.vmoptions override (in the location explained above) and add a line like this:

-Xmx2048m

Essentially, change updater options by changing Android Studio memory options, which helps Studio run better too!

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