The new and official Google Integrated Development Environment (IDE) Android Studio 2.0 with all its varied features is ready to be explored. How would you like to make your own Android applications and make these applications available to other users on Google Play Store? Can you do this easily? How can you achieve this?
This chapter will show you how to prepare your new Android Studio installation and help you take your first steps in the new environment. We will begin by preparing the system for the installation and downloading the required files. We will see the welcome screen that prompts when running Android Studio for the first time, and we'll configure the Android Software Development Kit (SDK) properly so that you have everything ready to create your first application.
These are the topics we'll be covering in this chapter:
Installing Android Studio
Running Android Studio for the first time
Configuring the Android SDK
A prerequisite to start working with Android Studio is to have Java installed on your system. The system must also be able to find the Java installation. This can be achieved by installing the Java Development Kit (JDK) on your system and then setting an environment variable named JAVA_HOME
, which points to the JDK folder in your system. Check this environment variable to avoid issues during the installation of Android Studio.
The Android Studio package can be downloaded from the Android developer tools web page at http://developer.android.com/sdk/index.html by clicking on the download button, as is shown in the next screenshot. This package will be an EXE
file for Windows systems, a DMG
file for Mac OS X systems, or a TGZ
file for Linux systems:

In Windows, launch the EXE
file. The default installation directory is \Users\<your_user_name>\AppData\Local\Android\android-studio
. The AppData
directory is usually a hidden directory.
In Mac OS X, open the DMG
file and drop Android Studio into your Applications
folder. The default installation directory is /Applications/Android\ Studio.app
.
In Linux systems, unzip the TGZ
file and execute the studio.sh
script located at the android-studio/bin/
directory.
If you have any problem in the installation process or in the following steps, you can get help about it and the known issues by checking Appendix, Getting Help.
Execute Android Studio and wait until it loads completely. This may take a few minutes the first time. The first time you execute Android Studio, you will be prompted by a welcome screen. As shown in the following screenshot, the welcome screen provides options to start a new project, open a project, import a project, or even perform more advanced actions, such as checking out a project from a version control system or modifying the configuration options:

Let's have a look at the various options available on the welcome screen:
Start a new Android Studio project: This creates a new Android project from scratch
Open an existing Android Studio project: This opens an existing project
Check out project from Version Control: This creates a new project by importing existing sources from a version control system
Import project (Eclipse ADT, Gradle, etc.): This creates a new project by importing existing sources from your system
Import an Android code sample: This imports a project containing the official Google code samples from GitHub (https://github.com/googlesamples)
The welcome screen, in addition to the main actions, also contains a configuration menu and a help menu, as described in the following:
Configure: This opens the configuration menu. The configuration menu has the following options:
SDK Manager: This opens the Android SDK tool that will be explained in Chapter 6, Tools.
Preferences: This opens the Android Studio preferences.
Plugins: This opens the plugins manager for Android Studio.
Import Settings: This imports the settings from a file (
.jar
).Export Settings: This exports the settings to a file (
.jar
).Settings Repository: This allows you to enter the URL of an external code repository.
Check for Update: This checks if there is an Android Studio update available.
Project Defaults: This opens the project default settings menu.
Settings: This opens the template project settings. These settings are also reachable through the Android Studio settings (Configure | Settings).
Project Structure: This opens the project and platform settings.
Run Configurations: This opens the run and debug settings.
Get Help: This opens the help menu:
Help Topics: This opens the Android Studio help, an online version
Tips of the Day: This opens a dialog with the tip of the day
Default Keymap Reference: This opens an online PDF containing the default keymap
Plugin Development: This opens a JetBrains website containing information for plugin developers
The essential feature that has to be correctly configured is the Android SDK. Although, Android Studio automatically installs the latest Android SDK available, so you should already have everything you need to create your first application. It is important to check it and learn how we can change it.
In the Android Studio welcome screen, navigate to Configure | Project Defaults | Project Structure. In SDK Location, you should have a selected Android SDK location as shown in the following screenshot. This selected SDK location is the default that will be used in our Android projects; however, we can change it later for specific projects that require special settings.

If you do not have an Android SDK configured in Android Studio, then we have to add it manually.
To accomplish this task, click on the ellipsis (...) button to add an Android SDK and then select the home directory for the SDK. Check whether you have it in your system by navigating to your Android Studio installation directory. You should find a folder named sdk
, which contains the Android SDK and its tools. The Android Studio installation directory may be in a hidden folder; so, click on the button highlighted in the following screenshot to Show Hidden Files and Directories:

If you wish to use another Android SDK location that is different from the one included with Android Studio, select this instead. For example, if you previously used the Android Development Tools (ADT) plugin for Eclipse, you already have an Android SDK installation in your system.
We have successfully prepared the system for Android Studio and installed our Android Studio instance. We ran Android Studio for the first time, and now we know the options available in the welcome screen. You have also learned how to configure our Android SDK and to install it manually, in case you wish to use a different version. Completing these tasks will leave your system with Android Studio running and configured to create your first project.
In the next chapter, you will learn about the concept of a project and how it includes everything the application requires, from classes to libraries. We will create our first project and discuss the different kinds of activities available in the wizard.