Search code examples
android-studiojvmjvm-arguments

Cannot set java.io.tmpdir for Android sdkmanager


I've installed Android Studio on a Fedora 25 system. When I went to use the emulator and create a new virtual device, I was offered some options to download a system image. This failed with the message that there is "no space left on device".

Since then, every time I go through the same steps, instead of getting to choose which image to download, I get "No system images available. Are you connected to the internet?" -- I am.

I then tried to run sdkmanager directly, and it craps out with:

Java HotSpot(TM) 64-Bit Server VM warning: Insufficient space for shared memory file:
   20622
Try using the -Djava.io.tmpdir= option to select an alternate temp location.

I presume this refers to /tmp, which is an in memory (tmpfs) filesystem with a 4GB upper bound, more or less none of which is in use. I am fine using somewhere else if more space is needed.

The sdkmanager launch script mentions:

#

 Add default JVM options here. You can also use JAVA_OPTS and SDKMANAGER_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'

I've tried three things in relation to this, using a location in a 100 GB filesystem that's half full:

  • Set via $_JAVA_OPTIONS. The JVM acknowledges this, but the app still fails
  • Set via $JAVA_OPTS and $SDKMANAGER_OPTS.
  • Edited directly into the sdkmanager launch script above.

None of these made any difference.


Solution

  • Deleting the installation (~/Android, ~/.AndroidStudio1.3, etc.), setting $_JAVA_OPTIONS, then re-running studio.sh) solved this problem.

    This implies the temp directory is being hardcoded somewhere when the app is run the first time.