WHAT'S IN THIS CHAPTER?
In this chapter you get started with setting up your development environment so you can start Android development with Android Studio. To that end, this chapter covers the basic installation instructions for Android Studio and its system requirements.
Although the Android operating system is based on Linux, the Android SDK and tools are available for all major operating systems, so you can set up your development environment for the operating system you are working with. Throughout this book we use Mac OS as the main environment; however, we cover Linux and Windows setup as well.
To use Android Studio, your development system must meet the minimum system requirements. This section lists the minimum requirements for Windows, Mac OS X, and Linux.
Microsoft Windows
Mac OS X
Linux
More details about system requirements can be found at https://developer.android.com/sdk/index.html#Requirements
.
Keep in mind that based on the size of the project, number of your dependencies, and emulator usage, you will likely need more resources. Typically, you will need at least 8GB of RAM and GPU support to run an emulator and work smoothly with better compilation times.
In most cases, developers need to test applications on multiple devices. Because they usually don't have enough devices to test adequately, they rely on emulators. Emulators require a high amount of storage and memory to run faster.
Java is essential for all operating systems. You must install Java SE (Standard Edition) Development Kit (JDK) for your operating system.
The JDK 7 download page can be accessed directly at http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
. When you navigate there, the page shown in Figure 1.1 appears.
To download the required installation binary or packages, select the Accept License Agreement option and then click the download link of the binary or package for your operating system.
The following sections provide installation instructions for Oracle Java version 7 on 64 bit Windows, Mac OS X, and Linux.
Java installation on Windows is pretty straightforward. As mentioned in the previous section, installing JDK provides JRE as well.
Download the jdk-7u79-windows-x64.exe
file and run it to start the installation.
Start the Java installation by clicking the jdk-7u79-windows-x64.exe
file after downloading it; you will see the dialog box shown in Figure 1.2.
After the installation finishes, you need to set the Windows 10 environment paths for Java to configure the system environment. You need to set a path for the JAVA_HOME
system variable.
C:Program FilesJavajdk1.7.0_79
for our 64 bit installation. If you installed the x86 version, your path would be different, such as C:Program Files (x86)Javajdk1.7.0_79
.Java used to be a part of Mac OS X and was shipped by Apple. This changed several years ago. Apple also decided to remove Java from Mac OS so JDK, which is provided by Oracle, needs to be installed separately.
jdk-7u79-macosx-x64.dmg
file from the page shown in Figure 1.1.Now JDK is ready to use on Mac OS X. You can check the installed JDK version from System Preferences of Mac OS X or type 'java –version'
in the terminal window to see whether Java installed properly.
Two types of installation packages are available for Linux. If you use a distribution with an rpm package manager like Fedora, you can download the rpm package and install Java via rpm. In this section you install JDK with the tar.gz
package on Ubuntu 14.04.
jdk-7u79-x64.tar.gz
from the download page shown in Figure 1.1 and extract it to the directory where you downloaded the tar.gz
file using the following command:
user@ubuntu$ tar xzvf jdk-7uXX-x64.tar.gz
That command will extract JDK into the jdk1.7.0_79
folder where you ran the command.
/usr/local/java
with the following command:
user@ubuntu$ mv jdk1.7.0_79 /usr/local/java
/etc/profile
file to set Java paths for your session. You can copy and paste the following lines to the end of the /etc/profile
file.
##Java Path
JAVA_HOME=/usr/local/java/jdk1.7.0_79
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
user@ubuntu$ sudo update-alternatives --install "/usr/bin/java" "java"
"/usr/local/java/jdk1.7.0_79/bin/java" 1
javac
:
user@ubuntu$ sudo update-alternatives --install "/usr/bin/javac" "javac"
"/usr/local/java/jdk1.7.0_79/bin/javac" 1
javaws
:
user@ubuntu$ sudo update-alternatives --install "/usr/bin/javaws" "javaws"
"/usr/local/java/jdk1.7.0_79/bin/javaws" 1
user@ubuntu$ sudo update-alternatives --set java
/usr/local/java/jdk1.7.0_79/bin/java
user@ubuntu$ sudo update-alternatives --set javac
/usr/local/java/jdk1.7.0_79/bin/javac
user@ubuntu$ sudo update-alternatives --set javaws
/usr/local/java/jdk1.7.0_79/bin/javaws
When you are done with the previous instructions, JDK and JRE will be ready to use when you restart Ubuntu. You can test whether Java installed correctly with version control. The command and output for that will look like this:
user@ubuntu~$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
Android Studio installation, like Java installation, differs by operating system. The following sections provide installation instructions for Windows, Mac OS X, and Linux platforms.
The direct link for the installation binaries is https://developer.android.com/sdk/index.html
.
The download link that's available when you go to this site will be correct for the operating system you are running, as shown in Figure 1.8.
This section covers the installation instructions for Android Studio on Microsoft Windows 10.
You are now ready to launch Android Studio on Windows. The first time you launch Android Studio, it asks you to select the theme for the IDE, as shown in Figure 1.12.
Finally, the installation completes and Android Studio is ready to work on Android application projects.
This section covers the basic steps to install Android Studio on Mac OS X.
Download the android-studio-ide-141.2178183-mac.dmg
file, which includes the Android Studio IDE installer for Mac OS.
After copying Android Studio to the Applications folder, Android Studio is ready to launch. You can then remove the .dmg
file from your system.
When you first launch Android Studio, it asks if you want to install Android SDK, the Android emulator, and Intel HAXM. It will also ask for the setup path for them, as shown in Figure 1.14.
If you selected Intel HAXM installation, you are asked for the amount of RAM memory you want to make available for the virtual devices, as shown in Figure 1.15.
After you click Finish from the Emulator Settings dialog box, a window with an installation summary will display as shown in Figure 1.16.
Navigate to the download page shown in Figure 1.9 to download Android Studio for Linux (android-studio-ide-141.2178183-linux.zip)
. After you've downloaded the file, follow these steps:
user@ubuntu$ unzip android-studio-ide-141.2178183-linux.zip
In this example you move the android-studio folder to the /opt
directory. You can select your own home directory as well, to make it available only to you.
user@ubuntu$ sudo mv android-studio /opt
./opt/android-studio/bin/studio.sh
command.
When you first launch Android Studio on Linux, it will display the screen shown in Figure 1.17.
Then the setup wizard will ask for Standard or Custom installation.
The wizard moves to the window shown in Figure 1.18 where you can select an Android Studio UI theme.
Figure 1.18 shows that the IntelliJ theme has been selected for this installation.
When you first launch Android Studio, you will see the Complete Installation dialog box shown in Figure 1.20, which enables you to import settings from a previous installation. Because we made a clean installation for this example, we selected the last option in the dialog box. If you have a previous installation with customization you'd like to import, you can specify your previous installation path (see the first two options in Figure 1.20).
Welcome to the world of Android development! When you finish installing Android Studio, you will finally reach the screen shown in Figure 1.21. Android Studio is ready to work with Android projects.
In this book, the main focus is on using Android Studio for development at an advanced level. Therefore, the book covers Android SDK and tools installations together with Android Studio. If you would like to explore Android SDK and tools separately, you can get the standalone installation binaries for your choice of operating system.
Standalone installation will help you either work with an IDE other than Android Studio, or to use the tools alone. The binaries are available at http://developer.android.com/sdk/index.html at the bottom of the page.
As you did in this chapter, you can download the compatible binary for your operating system and follow similar installation steps to continue. After you download and extract the SDK, you can add its location to Android Studio using Settings⇨Appearance & Behavior⇨System Settings⇨Android SDK⇨Android SDK Location.
In this chapter, we wanted to make sure you have all the necessary tools to work on the examples in the following chapters. We started by providing the requirements for the basic computer system needed to install the required software.
We then covered the installation of Android Studio for Windows, Mac OS, and Linux. We continue with what is required to begin Android application development in Android Studio in Chapter 2.