Android Studio for beginners, Part 1: Installation and setup

Install Android Studio and start your first Android project

For a few years now it’s been clear that Android dominates the mobile OS landscape. This Java-based technology has sparked a new gold rush, with programmers competing to make money from their mobile apps. Android jobs are also plentiful, as shown by a quick job search using Indeed.com.

To be successful, Android developers need a good grasp of the Java language, Android APIs, and Android app architecture. It’s also essential to use an appropriate and effective development environment. For many years, Eclipse IDE with the ADT plugin was the preferred platform for Android development. Today it’s Android Studio.

If you’re new to Android Studio, this tutorial series will get you started. I’ll briefly introduce the Android development platform, then show you how to download, install, and run the software. After that, we’ll spend most of our time actually using Android Studio to develop an animated mobile app. In Part 1 you’ll start up your first Android project and get to know the project workspace in Android Studio. In Part 2 you’ll code the app, learning how to use Android Studio to enter source code and resources into the project. Finally, in Part 3 we’ll build and run the app using both an emulated hardware device and an Amazon Kindle Fire HD 7″ tablet.

After you’re comfortable with developing a basic mobile app in Android Studio, we’ll explore more advanced topics like debugging, performance monitoring, and profiling with Android Studio. We’ll also look at extending Android Studio with three useful plugins.

Get started with Android Studio

Android Studio is Google’s officially supported IDE for developing Android apps. Based on IntelliJ IDEA, Android Studio is freely available under Apache License 2.0. The most recent stable version, 2.1.1, includes the following features:

A unified environment where you can develop for all Android devices.

Support for building Android TV apps and Android Wear apps.

Template-based wizards to create common Android designs and components.

A rich layout editor that lets users drag-and-drop user interface components, and that offers an option to preview layouts on multiple screen configurations.

Android-specific refactoring and quick fixes.

Gradle-based build support.

Lint tools to catch performance, usability, version compatibility, and other problems.

ProGuard integration and app-signing capabilities.

A fast and feature-rich emulator.

Instant Run to push changes to your running app without building a new APK (Application PacKage Zip file).

Download Android Studio

Google provides Android Studio for the Windows, Mac OS X, and Linux platforms. You can download this software from the Android Studio homepage. (You’ll also find the traditional SDKs, with Android Studio’s command-line tools, available from the Downloads page.) Before downloading Android Studio, make sure your platform meets one of the following requirements:

Running Android Studio

Android Studio presents a splash screen when it starts running:

On your first run, you’ll be asked to respond to several configuration-oriented dialog boxes. The first dialog box focuses on importing settings from any previously installed version of Android Studio.

If you’re like me, and don’t have a previously installed version, you can just keep the default setting and click OK. Android Studio will respond with a slightly enhanced version of the splash screen, followed by the Android Studio Setup Wizard dialog box:

When you click Next, the setup wizard invites you to select an installation type for your SDK components. For now I recommend you keep the default standard setting.

Click Next and verify your settings, then click Finish to continue.

The wizard will download and unzip various components. Click Show Details if you want to see more information about the archives being downloaded and their contents.

If your computer isn’t Intel based, you might get an unpleasant surprise after the components have completely downloaded and unzipped:

Your options are to either put up with the slow emulator or use an Android device to speed up development. I’ll discuss the latter option later in the tutorial.

Finally, click Finish to complete the wizard. You should see the Welcome to Android Studio dialog box:

You’ll use this dialog to start up a new Android Studio project, work with an existing project, and more. You can access it anytime by double-clicking the Android Studio shortcut on your desktop.

Your first Android Studio mobile app

The quickest way to get to know Android Studio is to use it to develop an app. We’ll start with a variation on the “Hello, World” application: a little mobile app that displays a “Welcome to Android” message.

In the steps that follow, you’ll start a new Android Studio project and get to know the project workspace, including the project editor that you’ll use to code the app in Part 2.

Starting a new project

From our setup so far, you should still have Android Studio running with the Welcome to Android Studio dialog box. From here, click Start a new Android Studio project. Android Studio will respond with the Create New Project dialog box shown in Figure 15.

Enter W2A (Welcome to Android) as the application name and javajeff.ca as the company domain name. You should then see C:\Users\jeffrey\AndroidStudioProjects\W2A as the project location. Click Next to select your target devices.

Android Studio lets you select form factors, or categories of target devices, for every app you create. I would have preferred to keep the default API 15: Android 4.0.3 (IceCreamSandwich) minimum SDK setting (under Phone and Tablet), which is supported by my Amazon Kindle Fire HD tablet. Because Android Studio doesn’t currently support this API level (even when you add the 4.0.3 system image via the SDK Manager), I changed this setting to API 14: Android 4.0 (IceCreamSandwich), which is also supported by my tablet.

Click Next, and you will be given the opportunity to choose a template for your app’s main activity. For now we’ll stick with Empty Activity. Select this template and click Next.

Next you’ll customize the activity:

Enter W2A as the activity name and main as the layout name, and click Finish to complete this step. Android Studio will respond that it is creating the project, then take you to the project workspace.

The project workspace is organized around a menu bar, a tool bar, a work area, additional components that lead to more windows (such as a Gradle Console window), and a status bar. Also note the Tip of the Day dialog box, which you can disable if you like.

Accessing AVD Manager or SDK Manager from menu and tool bar

To access the traditional AVD Manager or SDK Manager, select Android from the Tools menu followed by AVD Manager or SDK Manager from the resulting pop-up menu (or click their tool bar icons).

The project and editor windows

When you enter the project workspace, W2A is identified as the current project, but you won’t immediately see the project details. After a few moments, these details will appear in two new windows.

The project window is organized into a tree whose main branches are App and Gradle Scripts. The App branch is further organized into manifests, java, and res subbranches:

manifests stores AndroidManifest.xml, which is an XML file that describes the structure of an Android app. This file also records permission settings (where applicable) and other details about the app.

java stores an app’s Java source files according to a package hierarchy, which is ca.javajeff.w2a in this example.

res stores an app’s resource files, which are organized into drawable, layout, mipmap, and values subbranches:

drawable: an initially empty location in which to store an app’s artwork

Video Tutorials

OBJECTIVE...!

I’m Rajashekar,
Core Android Developer with complimenting
skills as a developer from India.
I cherish taking up complex problems and
turning them into beautiful interfaces.
My love for decrypting the logic and structure of
coding keeps me pushing towards writing elegant
and proficient code, whether it is Android, PHP
or any other platforms.