Android Studio likes to run in Oracle's runtime, and the cache and config files it stores in the user's home directory (including virtual device images) start to eat up too much space on our network home mount. Here's how to set up Oracle JDK and Android Studio on Fedora Workstation, and configure Android Studio to keep its files on a local drive.
Get the latest Java SE Development Kit "critical patch update" release from oracle.com, and if OpenJDK is already installed then configure these alternatives:
sudo yum localinstall ~/Downloads/jdk-7u67-linux-x64.rpm
sudo alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000
sudo alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 200000
sudo alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000
sudo alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000
sudo alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 200000
Check the version to make sure Oracle's version is running
[jamchamb@glottis ~]$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
[jamchamb@glottis ~]$ javac -version
javac 1.7.0_67
Set up the JAVA_HOME
environment variable to point to
Oracle's Java location in ~/.bash_profile
, or possibly
an /etc/profile.d/
file.
export JAVA_HOME="/usr/java/latest"
Install these 32-bit dev libraries
sudo yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686
Download Android Studio from https://developer.android.com/sdk/installing/studio.html
Download Android SDK (tools only) from https://developer.android.com/sdk/index.html
Run df
to figure out which local partition is suitable for installing AS to, and
make a directory there. For example,
$ df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sda3 50G 9.5G 38G 21% /
/dev/sda1 477M 122M 327M 28% /boot
/dev/sda5 405G 28G 357G 8% /home
192.168.151.25:/vol/oss/home 50G 39G 12G 78% /heroes/u1
I created a directory under /home
: /home/jamchamb-local
. Extract the SDK and IDE to
this directory.
tar -C /home/jamchamb-local -xzf ~/Downloads/android-sdk_r23.0.2-linux.tgz
tar -C /home/jamchamb-local -xzf ~/Downloads/android-studio-bundle-135.1339820-linux.tgz
Edit android-studio/bin/idea.properties
to configure IDEA to use your local directory
for configuration files, etc. Uncomment and alter the lines for idea.config.path
and
idea.system.path
:
idea.config.path=${idea.home.path}/../.AndroidStudio1.2/config
idea.system.path=${idea.home.path}/../.AndroidStudio1.2/system
To keep the local Maven repository on disk, update (or create) ~/.m2/settings.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/home/jamchamb-local/android-sdk-linux/extras/android/m2repository/</localRepository>
<localRepository>/home/jamchamb-local/android-sdk-linux/extras/google/m2repository/</localRepository>
</settings>
Then run android-studio/bin/studio.sh
to start Anroid Studio, and in the
settings change the Gradle service directory to be /home/jamchamb-local/.gradle
.
Now you can open the Android SDK Manager and start downloading required packages.
Normally this includes:
- Android SDK Platform-tools
- Android SDK Build-tools
- An SDK platform, e.g. Android 4.4 (API 19)
- Android Support Repository
- Android Support Library
- Google Play services
- Google Repository