Skip to content

Development with Linux

Mikhail Kulesh edited this page Jan 17, 2018 · 1 revision

Environment variables for console tools

There are two important environment variables necessary when a console is used:

  • Gradle home directory. Gradle uses the directory .gradle in our home directory as the default Gradle user home directory. This directory is huge, sometime is necessary to move it to another mount. To change the Gradle user home directory we can set the environment variable GRADLE_USER_HOME and point it to another directory:
setenv GRADLE_USER_HOME /work/android/gradle
  • Android SDK directory. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable:
setenv ANDROID_HOME /work/android/sdk

Build project with Gradle Wrapper

The Gradle Wrapper is the preferred way of starting a Gradle build. It consists of a batch script for Windows and a shell script for OS X and Linux. These scripts allow you to run a Gradle build without requiring that Gradle be installed on your system. This used to be something added to your build file, but it’s been folded into Gradle, so there is no longer any need. Instead, you simply use the following command.

/work/android/gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3/bin/gradle wrapper --gradle-version 3.3

Temporary directory for SDK manager for Android Studio

In order to be able to download SDK components, the system tmp directory shall not be used for SDK manager since it usually does not have enough capacity. We shall change the location of the temporary directory used by the Java Virtual Machine running Android Studio (and SDK manager). In Android Studio 2.0 or later, select Help -> Edit Custom VM Options. This will create a copy of the installation's vmoptions file in your own configuration directory and open it in the editor. Add the following line and restart:

-Djava.io.tmpdir=<directory>

where is an absolute path to a directory in a partition with enough space. If doesn't exist, it will be created the next time Android Studio is started. For more details, see this