Module 0253: Getting started with Android Studio

Tak Auyeung, Ph.D.

January 17, 2017

1 About this module

2 Getting Android Studio

Android Studio is available for from Android. The best method to download and install Android Studio is go to the developer Android home page.

A few notes on installing Android Studio.

First, it can take up a lot of disk space. Depending on how many versions of Android you want to support and how many AVD (Android Virtual Devices) you want to install, Android Studio can easily take up 20GB of storage!

Second, you can install Android Studio (at least in Linux) without administrator permissions. However, in Windows, you may need administrator permissions to have the virtualization accelerator driver installed.

Interestingly, Oracle JDK does not seem to be required any more as of Android Studio 2.2 (the current version at the time of writing this module). This is because Android Studio comes bundled with OpenJDK8.

If you plan to install use Android Studio from an extermal disk, you are highly recommended to use an external hard disk drive or and external SSD (solid state drive). Although thumb drives may have the capacity, they are generally too slow to run such a massive tool!

3 Running Android Studio

Running Android Studio should be as easy as any other program in Windows and Mac OSX. In Linux, the default installation path is as follows:

    ˜/android_studio/bin/studio.sh

The first time you run Android Studio, it is likely to ask to be updated. Go ahead and let it update itself.

4 Components to install

Android Studio has many optional components. Specifically, Android SDK (software development kit) supports a variety of platforms. To investigate these options, go to the following menu: Android Studio, Configure, SDK Manager.

Then, in SDK Manager, explore the following tabs.

4.1 Appearance & Behavior, System Settings, Android SDK

This manager lets you select which version (in SDK Platforms) of Android you want to support, and what tools (SDK Tools) you want to use for development purposes.

There is no need to include the kitchen sink. You can always come back to this manager to install additional components. Since Android is a fast moving platform, it is not a bad idea to start with the second latest released version (platform) for new development!

5 Start a Project

In the main screen of Android Studio, click “Start a new Android Studio Project”.

The next screen prompt you for a few key attribute of the project that is not easy to change later on.

Click Next. The next screen lets you select what devices will run your app. The “Minimum SDK” drop down box lets you select a version of Android for a specific category of Android devices. Note how the tool reports the percentage of devices that are active on the Google Play Store.

Click “help me choose” to display a visual picture of the marketshare of each version. In this API Version Distribution screen, click on a version to display unique features of that platform.

This can be quite important depending on what your app requires. For example, if your app adds widgets to the lock screen, then API level 17 (version 4.2) is the minimum version that you need to support.

It is not a bad idea to go through the summary of various platforms to see what features are available and when those features are added to Android.

At the time of writing this module, the majority platform is KitKat (version 4.4).

Click Next.

The next screen lets you add a default “activity” to the app. The word “activity” has a specific meaning in Android app development. Loosely, it is a “screen” of an app. Those who migrate from AppInventor can equate a “screen” in AppInventor to an “activity” in proper Android development.

Obviously, your app should not be limited to only one activity! This configuration screen is merely creating the first screen for you. For this exercise, let us choose “Empty Activity”, which gives you a blank slate.

Click Next.

We are almost there! The next screen lets you choose the name of the activity that was just created. Note that the Activity Name is going to be the name of a Java class, so it has to follow the camel case convention with a first upper case character.

The Layout Name, on the other hand, is only an identifier. I would leave these names as defaults for now.

Click Finish.

After a brief moment (depending on the performance of computer), the project is generated.

6 The Project Screen

The project screen is quite busy, but that is almost necessary due to the complexity of an app.

The top of the screen is the usual menu bar. Right below that is the tool bar. This is fairly standard for just about any programs.

Below the tool bar is where the fun begins! This is a hierarchical exploration bar. The left is the top level. As you click on one item, it opens a menu to let you select one of the choices (if any) of the next level.

Below the exploration bar there are 3 panes.

The leftmost pane where the words are side way let you explore some less frequently needed items. We will stay with ”Project” most of the time.

The Middle pane is where you can see the hierarchy of project files. when “Project” is selected on the leftmost pane. The rightmost pane is where most editing happens. This editing pane has its own tabs so you can keep multiple documents open.

7 Let’s run it!

Although our app does not do a single thing, let’s run it! To run an app, you can click the green triangle that points to the right on the tool bar.

If you do not have a AVD (Android Virtual Device) created, Android Studio will ask to create one. The AVD configuration screen guides you through the steps to create an AVD.

You can also test run your app on a real Android device. To do this, you will need to have the developer option enabled. The tool adb (Android debugging bridge) can communicate via USB or wi-fi.

When this app runs, it is not exactly exciting because it just displays a screen that says “Hello World!”