Note: WebUpd8 team's PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn't have any Java files. More information can be found on PPA's page on Launchpad. Hence this method no longer works and exists because of historical reasons.
Installing Android Studio
Download Android Studio from here, use All Android Studio Packages
Extract the archive file into an appropriate location for your applications, eg: /opt. Use the filename of your downloaded archive, in my example android-studio-ide-141.2178183-linux.zip
The easiest method to install Android Studio on Ubuntu is to just use the snap package from Ubuntu Software store. No need to download Android Studio as zip, try to manually install it, run umake and other scripts, add PPAs or fiddle with Java installation. This snap package bundles the latest Android Studio along with OpenJDK and all the necessary dependencies. Neat and clean!
Step 1: Install Android Studio
Search "android studio" in Ubuntu Software, select the first entry that shows up and install it:
Or if you prefer the command line way, run this in Terminal:
sudo snap install --classic android-studio
Step 2: Install Android SDK
Open the newly installed Android Studio from dashboard:
Don't need to import anything if this is the first time you're installing it:
The Setup Wizard'll guide you through installation:
Select Standard install to get the latest SDK and Custom in-case you wanna change the SDK version or its install location. From here on, it's pretty straightforward, just click next-next and you'll have the SDK downloaded and installed.
Step 3: Setting PATHs (Optional)
This step might be useful if you want Android SDK's developer tool commands like adb, fastboot, aapt, etc available in Terminal. Might be needed by 3rd party dev platforms like React Native, Ionic, Cordova, etc and other tools too. For setting PATHs, edit your ~/.profile file:
If you changed SDK location at the end of Step 2, don't forget to change the line export ANDROID_HOME=${HOME}/Android/Sdk accordingly. Do a restart (or just logout and then log back in) for the PATHs to take effect.
Tested on Ubuntu 18.04 LTS & 16.04 LTS. Should technically work on any Ubuntu version with snap support (16.04 LTS and newer). Would work on 14.04 LTS too if you install support for snap packages first.
In the eve of 2018, the most voted answer is still awesome, but seems a bit outdated, and as I run into this recently, I decided to share my fresh experience here.
1. Installing Java
Since Android Studio 2.2 was released you won’t need to install any JDK yourself in most cases, since it’s brought with the IDE.
You can get Android Studio archive from here. Nothing special, just wait until loading is finished :)
Google is a registered LANANA provider, so in order to comply the Linux FSH contract (part 3.13 /opt) I would like to suggest unpacking the archive to the google/android-studio folder:
3.1 [Optional] Change write permission for Android Studio folder
You may find setting write permissions for all users convenient when it comes to updating Android Studio. However it’s not widely used, and seems to violate the principle of least privilege. However, just in case, if you like this way better just execute in terminal:
sudo chmod o+w /opt/google/android-studio/
Alternatively you can always run Android-Studio on behalf of root and performs all updates you need without this step involved.
4. Creating Android SDK directory
I don’t embrace the idea that each user should have his own copy of Android SDK tools (build tools, source codes, system images, etc..) but Android Studio works exactly that way (it's likely because of permissions issue). Let's make it use another folder shared among all users in the system.
The last command changes permissions so every user in the system is able to edit this android-sdk folder (installing and removing packages).
4.2 Setting Environment Variables
Android Studio is still pointing to its own path at this moment. To make Android Studio install SDKs in shared folder, we need to specify environment variables. Currently there are two variables pointing to SDK folder: ANDROID_HOME and ANDROID_SDK_ROOT. The first is deprecated, but Android Studio won’t use ANDROID_SDK_ROOT when launching it first time even if it’s specified, so i would recommend to specify both variables. To keep things consistent and clear, let’s specify them in a separate shell for the android-studio in the profile.d folder (so you can remove them later in case of removing Android Studio):
If you going to use gradlew commands via CLI interface, it will be useful to add JAVA_HOME pointing to embedded JRE (otherwise gradle won't be able to locate it)
Since we changed permissions for the SDK folder (/opt/google/android-sdk/), we don’t need any special permissions to write in it. Just run android-studio on behalf of your current user:
/opt/google/android-studio/bin/studio.sh
Now follow setup wizard instructions. Eventually you will hit Downloading Components window. It may take for a while until required components are installed. As we took care about all required libraries and software from very beginning (part 2), this process should be finished without any error.
Upon first launch Android Studio installs only latest SDK platform (at the time of writing API 27). To make your toolset viable, you need at least 2-3 more older SDK platforms installed (here you can find the dashboard showing actual demand for different APIs version). In order to get them, from the Android Studio welcoming screen, click “Configure” and choose the SDK Manager option.
From here you can choose whatever you need to develop Android apps.
P.S. You can actually install everything from the list (even obsolete packages), but it will take ages to download.
6. Creating desktop entry
Currently Android Studio offers embedded feature in order to create desktop entry. We need to run Studio with root permissions, so it's possible to do that for all users in the system, :
sudo -E /opt/google/android-studio/bin/studio.sh
P.S. -E option is needed to keep our environment variables (ANDROID_HOME/ANDROID_SDK_ROOT) available while sudoing.
You will have to pass the same Setup Wizard again (it’s being performed for the root user now) and once you hit the Welcoming screen, you can find option Create Desktop Entry from “Configure” menu:
In the dialog box that opens, ensure that “Create the entry for all users” checkbox is checked and click OK.
Now you can close Android Studio and open from Unity Launcher!
P.S. For those who are interested in where the entry was created and what is inside, you can find it in /usr/share/applications/jetbrains-studio.desktop:
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Icon=/opt/google/android-studio/bin/studio.png
Exec="/opt/google/android-studio/bin/studio.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-studio
A. [Bonus] Uninstall script
And for sweets I prepared a shell script that you can use to remove your Android Studio altogether, including SDK folder, settings, emulators and cache folders from all users. It’s tailored for the steps above, but the paths are in the top of the file, so you can easily adapt it for your own configuration. Here we go:
#!/bin/bash
####################################
#
# Android Studio uninstalling script
#
####################################
# Ensure root permissions
if [ $(whoami) != 'root' ]; then
echo "Must be root to run $0"
exit 1;
fi
# Variables
studio_folders=(.android .AndroidStudio* .gradle) # look for these folders
paths=(/home/,2 /root/,1) # in these folders
studio_path="/opt/google/android-studio/"
sdk_path="/opt/google/android-sdk/"
env_variables="/etc/profile.d/android_studio.sh"
# Functions
deletefolders() {
local name_expression=( \( -name "${studio_folders[0]}" )
for (( i=1; i<${#studio_folders[*]}; i++ )); do
name_expression[${#name_expression[*]}]=-o
name_expression[${#name_expression[*]}]=-name
name_expression[${#name_expression[*]}]="${studio_folders[$i]}"
done
name_expression[${#name_expression[*]}]=\)
find "$1" -maxdepth "$2" -type d ${name_expression[*]} -exec rm -rf {} \;
}
# Commands
for path in ${paths[*]}; do
deletefolders ${path%,*} ${path#*,}
done
rm -r $studio_path
rm -r $sdk_path
rm $env_variables
Please be advised that the wildcard .AndroidStudio* is used in the script to remove settings of different android studio versions. If you keep something valuable in the hidden folder with the name starting with ‘.AndroidStudio’, it’s also gonna be removed.
For those who not familiar with the notion of shell scripts, here are simple steps that should help:
Open terminal, write command nano. A nano editor will be opened in
terminal window.
Copy the text from the script above and past it in
the terminal window with nano opened (Ctrl+Shift+V)
Click Ctrl+O in order to save file, choose the path and name of the file with .sh extension:
Exit the nano (ctrl+X)
In the terminal you need to apply this command to just created file to make it runnable (supposing you saved your script in ~/Documents directory and named it android_uninstall.sh):
chmod u+x ~/Documents/android_uninstall.sh
Now you can run the script specifying path to it in terminal. Keep in mind that without root permission it won’t remove folders from the /opt/ directory, so script will ask you for these permissions before doing anything.
That’s it. I’m actually quite new in Linux kind OSs, so feel free to correct me in comments as needed.
Go to Android Studio > Tools > Create desktop Entry
Prerequisites:
OpenJDK comes pre-installed, so use that.
Android Studio notifies you with a small bubble dialog when an update is available for the IDE, but you can manually check for updates by clicking Help > Check for Update
FYI
You can switch between JDKs, by changing the JDK path in the settings. JDKs are installed under /usr/lib/jvm
$ ls /usr/lib/jvm/
default-java java-1.5.0-gcj-6-amd64 java-1.8.0-openjdk-amd64 java-8-openjdk-amd64
Here in my case /usr/lib/jvm/default-java is a symlink to /usr/lib/jvm/java-8-openjdk-amd64
Android Studio is available as a snap package in all currently supported versions of Ubuntu. The Android Studio snap package was the 5th most popular snap package in 2018. To install it open the terminal and type:
sudo snap install android-studio --classic
Android Studio provides the fastest tools for building apps on every type of Android device.
World-class code editing, debugging, performance tooling, a flexible build system, and an instant build/deploy system all allow you to focus on building unique and high quality apps.
System Requirements for Android Studio
3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator
2 GB of available disk space minimum, 4 GB recommended
Installing Java
After that
Installing Android Studio
Download Android Studio from here, use All Android Studio Packages
Extract the archive file into an appropriate location for your applications, eg:
/opt
. Use the filename of your downloaded archive, in my exampleandroid-studio-ide-141.2178183-linux.zip
To launch Android Studio, navigate to the
/opt/android-studio/bin
directory in a terminal and execute./studio.sh
. Or use a desktop file, see below.You may want to add
/opt/android-studio/bin
to your PATH environmental variable so that you can start Android Studio from any directory.Create a desktop file
Create a new file
androidstudio.desktop
by running the command:nano ~/.local/share/applications/androidstudio.desktop
and add the lines below
Installing Android SDK (if necessary)
Click the marked button
Get the latest SDK tools
As a minimum when setting up the Android SDK, you should download the latest tools and Android platform:
Open the Tools directory and select:
Open the first Android X.X folder (the latest version) and select:
Get the support library for additional APIs
The Android Support Library provides an extended set of APIs that are compatible with most versions of Android.
Open the
Extras
directory and select:Get Google Play services for even more APIs
To develop with Google APIs, you need the Google Play services package:
Open the
Extras
directory and select:Install the packages
Once you've selected all the desired packages, continue to install:
The easiest method to install Android Studio on Ubuntu is to just use the snap package from Ubuntu Software store. No need to download Android Studio as zip, try to manually install it, run umake and other scripts, add PPAs or fiddle with Java installation. This snap package bundles the latest Android Studio along with OpenJDK and all the necessary dependencies. Neat and clean!
Step 1: Install Android Studio
Search "android studio" in Ubuntu Software, select the first entry that shows up and install it:
Or if you prefer the command line way, run this in Terminal:
Step 2: Install Android SDK
Open the newly installed Android Studio from dashboard:
Don't need to import anything if this is the first time you're installing it:
The Setup Wizard'll guide you through installation:
Select Standard install to get the latest SDK and Custom in-case you wanna change the SDK version or its install location. From here on, it's pretty straightforward, just click next-next and you'll have the SDK downloaded and installed.
Step 3: Setting PATHs (Optional)
This step might be useful if you want Android SDK's developer tool commands like adb, fastboot, aapt, etc available in Terminal. Might be needed by 3rd party dev platforms like React Native, Ionic, Cordova, etc and other tools too. For setting PATHs, edit your
~/.profile
file:and then add the following lines to it:
If you changed SDK location at the end of Step 2, don't forget to change the line
export ANDROID_HOME=${HOME}/Android/Sdk
accordingly. Do a restart (or just logout and then log back in) for the PATHs to take effect.Tested on Ubuntu 18.04 LTS & 16.04 LTS. Should technically work on any Ubuntu version with snap support (16.04 LTS and newer). Would work on 14.04 LTS too if you install support for snap packages first.
@A.B answer is correct and complete. I just add that alternatively you can easily install an up-to-date Android Studio using Canonical's Ubuntu Make.
Installing Ubuntu Make :
For Ubuntu 14.04LTS
For Ubuntu 15.10 and up
Ubuntu Make is already in official repositories, run :
Note that umake version should be 16.05 to be able to download android studio, check by running
If not, use the Ubuntu 14.04 method to install it.
Installing Android Studio :
There may be an error message related to license that may be corrected using an additional parameter:
Uninstall Android Studio :
In the eve of 2018, the most voted answer is still awesome, but seems a bit outdated, and as I run into this recently, I decided to share my fresh experience here.
1. Installing Java
Since Android Studio 2.2 was released you won’t need to install any JDK yourself in most cases, since it’s brought with the IDE.
Reference for more details
2. Installing prerequisite software
The following command should be run in the first place, so we can avoid some problems with the AVD tool in future:
Reference for more details
3. Downloading and Unpackaging Android Studio
You can get Android Studio archive from here. Nothing special, just wait until loading is finished :)
Google is a registered LANANA provider, so in order to comply the Linux FSH contract (part 3.13 /opt) I would like to suggest unpacking the archive to the
google/android-studio
folder:3.1 [Optional] Change write permission for Android Studio folder
You may find setting write permissions for all users convenient when it comes to updating Android Studio. However it’s not widely used, and seems to violate the principle of least privilege. However, just in case, if you like this way better just execute in terminal:
Alternatively you can always run Android-Studio on behalf of root and performs all updates you need without this step involved.
4. Creating Android SDK directory
I don’t embrace the idea that each user should have his own copy of Android SDK tools (build tools, source codes, system images, etc..) but Android Studio works exactly that way (it's likely because of permissions issue). Let's make it use another folder shared among all users in the system.
4.1 Create directory
Make the android-sdk folder for future use:
The last command changes permissions so every user in the system is able to edit this android-sdk folder (installing and removing packages).
4.2 Setting Environment Variables
Android Studio is still pointing to its own path at this moment. To make Android Studio install SDKs in shared folder, we need to specify environment variables. Currently there are two variables pointing to SDK folder: ANDROID_HOME and ANDROID_SDK_ROOT. The first is deprecated, but Android Studio won’t use ANDROID_SDK_ROOT when launching it first time even if it’s specified, so i would recommend to specify both variables. To keep things consistent and clear, let’s specify them in a separate shell for the android-studio in the profile.d folder (so you can remove them later in case of removing Android Studio):
4.2.1 Setting JAVA_HOME Variable
If you going to use gradlew commands via CLI interface, it will be useful to add JAVA_HOME pointing to embedded JRE (otherwise gradle won't be able to locate it)
Now you need log out the system and log in back to apply this new script.
Reference for more details
5. Installing SDK
Since we changed permissions for the SDK folder (
/opt/google/android-sdk/
), we don’t need any special permissions to write in it. Just run android-studio on behalf of your current user:Now follow setup wizard instructions. Eventually you will hit Downloading Components window. It may take for a while until required components are installed. As we took care about all required libraries and software from very beginning (part 2), this process should be finished without any error.
Upon first launch Android Studio installs only latest SDK platform (at the time of writing API 27). To make your toolset viable, you need at least 2-3 more older SDK platforms installed (here you can find the dashboard showing actual demand for different APIs version). In order to get them, from the Android Studio welcoming screen, click “Configure” and choose the SDK Manager option.
From here you can choose whatever you need to develop Android apps. P.S. You can actually install everything from the list (even obsolete packages), but it will take ages to download.
6. Creating desktop entry
Currently Android Studio offers embedded feature in order to create desktop entry. We need to run Studio with root permissions, so it's possible to do that for all users in the system, :
P.S. -E option is needed to keep our environment variables (ANDROID_HOME/ANDROID_SDK_ROOT) available while sudoing.
You will have to pass the same Setup Wizard again (it’s being performed for the root user now) and once you hit the Welcoming screen, you can find option Create Desktop Entry from “Configure” menu:
In the dialog box that opens, ensure that “Create the entry for all users” checkbox is checked and click OK.
Now you can close Android Studio and open from Unity Launcher!
P.S. For those who are interested in where the entry was created and what is inside, you can find it in
/usr/share/applications/jetbrains-studio.desktop
:A. [Bonus] Uninstall script
And for sweets I prepared a shell script that you can use to remove your Android Studio altogether, including SDK folder, settings, emulators and cache folders from all users. It’s tailored for the steps above, but the paths are in the top of the file, so you can easily adapt it for your own configuration. Here we go:
Please be advised that the wildcard .AndroidStudio* is used in the script to remove settings of different android studio versions. If you keep something valuable in the hidden folder with the name starting with ‘.AndroidStudio’, it’s also gonna be removed.
For those who not familiar with the notion of shell scripts, here are simple steps that should help:
Click Ctrl+O in order to save file, choose the path and name of the file with .sh extension:
Exit the nano (ctrl+X)
In the terminal you need to apply this command to just created file to make it runnable (supposing you saved your script in
~/Documents
directory and named it android_uninstall.sh):Now you can run the script specifying path to it in terminal. Keep in mind that without root permission it won’t remove folders from the
/opt/
directory, so script will ask you for these permissions before doing anything.That’s it. I’m actually quite new in Linux kind OSs, so feel free to correct me in comments as needed.
Add the android-studio repository:
Then install:
More information can be found at https://mfonville.github.io/android-studio/
Quoted from http://ubuntuhandbook.org/index.php/2014/11/install-android-studio-ubuntu-14-04-ppa/
Android Studio depends on Java, and Oracle Java 7 or 8 is recommended
Add the Android Studio PPA
Then update package lists and install it:
Once installed, start the setup wizard from the Unity Dash or just run command
If you are running a 64-bit version of Ubuntu (16.04), you need to install some 32-bit libraries with the following command:
or
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
So that you don't have this error:
For more read this doc
For ubuntu 16.04, the syntax is as follows.
It is not required that you use a package archive.
Installation
Download the zip file from here:
https://developer.android.com/studio/index.html#linux-bundle
Extract it some where under
/home/....
Run
./bin/sudio.sh
To create a desktop entry:
Prerequisites:
OpenJDK comes pre-installed, so use that.
Android Studio notifies you with a small bubble dialog when an update is available for the IDE, but you can manually check for updates by clicking
Help > Check for Update
FYI
You can switch between JDKs, by changing the JDK path in the settings. JDKs are installed under
/usr/lib/jvm
Here in my case
/usr/lib/jvm/default-java
is a symlink to/usr/lib/jvm/java-8-openjdk-amd64
So I'd use that as the JDK path in the settings.
Android Studio is available as a snap package in all currently supported versions of Ubuntu. The Android Studio snap package was the 5th most popular snap package in 2018. To install it open the terminal and type:
Android Studio provides the fastest tools for building apps on every type of Android device.
World-class code editing, debugging, performance tooling, a flexible build system, and an instant build/deploy system all allow you to focus on building unique and high quality apps.
System Requirements for Android Studio