Home Mobile Android Studio 2 Essentials - Second Edition

Android Studio 2 Essentials - Second Edition

By Belén Cruz Zapata
books-svg-icon Book
eBook $29.99 $20.98
Print $38.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $29.99 $20.98
Print $38.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Installing and Configuring Android Studio
About this book
Android Studio 2, the official IDE for Android application development, dramatically improves your workflow by letting you quickly see changes running on your device or emulator. It gives developers a unique platform by making app builds and deployment faster. This book will get you up and running with all the essential features of Android Studio 2 to optimize your development workflow. Starting off with the basic installation and configuration of Android Studio 2, this book will help you build a new project by showing you how to create a custom launcher icon and guiding you to choose your project. You will then gain an insight into the additional tools provided in Android Studio, namely the Software Development Kit (SDK) Manager, Android Virtual Device (AVD) Manager, and Javadoc. You’ll also see how to integrate Google Play Services in an Android project. Finally, you’ll become familiar with the Help section in Android Studio, which will enable you to search for support you might require in different scenarios.
Publication date:
June 2016
Publisher
Packt
Pages
172
ISBN
9781786467959

 

Chapter 1. Installing and Configuring Android Studio

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

 

Preparing for installation


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.

 

Downloading 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:

 

Installing Android Studio


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.

 

Running Android Studio for the first time


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

 

Configuring the Android SDK


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.

 

Summary


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.

About the Author
  • Belén Cruz Zapata

    Beln Cruz Zapata received her engineer's degree in computer science from the University of Murcia in Spain, specializing in software technologies, and intelligent and knowledge technologies. She earned an MSc in computer science and is now working on her PhD in the Software Engineering Research Group from the University of Murcia. During the 2013/2014 academic year, Beln collaborated with the Universit Mohammed V-Soussi, in Rabat, Morocco. Her research is focused on usability applied to mobile health (mHealth) applications. Beln is currently working as a mobile developer for Android and iOS in the San Francisco Bay area. She is also the author of the book: Testing and Securing Android Studio Applications, Packt Publishing. To follow her projects, you can visit her personal webpage at http://www.belencruz.com and you can follow her on Twitter: @belen_cz.

    Browse publications by this author
Latest Reviews (2 reviews total)
Good content. I like the structure of the book.
Android Studio 2 Essentials - Second Edition
Unlock this book and the full library FREE for 7 days
Start now