1 of 30

Android Studio Setup

Prepare your environment for Android

2 of 30

Overview

  • Install Android Studio IDE
  • Basic setup of Android Studio - Editor settings, Android SDKs and tools
  • Download sample app using Git and import it into Android Studio
  • Setting up the official Android emulator to run different Android OSes
  • Run Sample App

3 of 30

Android Studio -- Why?

Android Studio is the latest development environment Google recommends for Android. It is based on the JetBrains IntelliJ IDEA editor.

When developing apps for Android, we will need Java SDK, Android SDK as well as the Android Studio IDE.

4 of 30

Installing Android Studio

Download Android Studio which includes everything needed to get started.

1. Download Android Studio

https://developer.android.com/studio

2. For OS-specific instructions, follow: https://developer.android.com/studio/install.html?pkg=studio

3. Launch Android Studio Application

5 of 30

Setting up Android Studio I

A newly installed Android Studio should now prompt you to use the wizard to setup the Android Studio.

  • Click “Next” to continue through the wizard.
  • Select the “Standard” installation.
  • Click “Finish

6 of 30

Setting up Android Studio II

If installation succeeds, you should see the “Silent Installation Pass!” in “Show Details”�

Click “Finish

7 of 30

Configure

Select “Configure

and then “Preferences” in the bottom menu.

8 of 30

Configure Line Numbers

1. Find Editor → General → Appearance

2. Enable “Show line numbers”

9 of 30

Configure Imports

1. Find Editor → General → Auto Import

2. Set “Imports on Paste” to “All

3. Click “Optimize imports on the fly”

4. Check “Add unambiguous imports on the fly”

5. Exclude android.R from auto-imports

10 of 30

Disable Instant Run

1. Choose Preferences menu

2. Type “Instant Run”

3. Uncheck “Enable Instant Run to hot swap code/resource changes on deploy”

(You may need to build a project first before this option is no longer greyed out.)

11 of 30

Android Emulator

Running Android Apps in Android Studio

12 of 30

Emulator -- Why?

Android Development requires us to try the apps we are building while they are being built.

While this can be done by plugging in an Android device, usually it is easier to use an Emulator.

An Emulator runs the app in a virtual Android on your computer through Android Studio.

Android now includes an emulator that works well. The previous third-party emulator called Genymotion no longer is needed.

13 of 30

Create Virtual Device

Select Create Virtual Device to add new virtual device

14 of 30

Setup Virtual Device I

Select Pixel as the device to run the Android OS on

15 of 30

Setup Virtual Device II

Select Recommended tab. Then select API 28. If you haven’t downloaded, click the Download link.

16 of 30

Setup Virtual Device III

Verify the configuration. It is ok to leave the default configuration as is. Click on Show Advanced Settings to know more about the configuration.

Then click Finish

17 of 30

Launch Android Emulator

For the virtual device that you create, click on the "Green Play Icon" to launch in the emulator. Starting the emulator for the first time make take a few minutes. Don't close the window once it has booted.

18 of 30

Troubleshoot: Intel HAXM (1)

For OS-X machines, make sure to go to System Preferences -> Security & Privacy and click Allow button if system software from “Intel Corporation Apps” is shown.

19 of 30

Troubleshoot: Intel HAXM (2)

Error message: “X86 emulation currently requires hardware acceleration” requires you to enable virtualization technology (VTx) in the computer’s BIOS menu.

20 of 30

Troubleshoot: Intel HAXM (3)

Enabling VTx requires entering the BIOS menu by restarting the machine and enabling the option.

Here are the specific vendor instructions for booting in BIOS:

  • Asus/Dell
  • HP
  • Lenovo

Don’t forget to save after making the change!

21 of 30

Troubleshoot: Intel HAXM (4)

OSX machines usually have virtualization support already enabled.

For more information/help you can refer to https://developer.android.com/studio/run/emulator-acceleration.html

22 of 30

Testing on a Physical Device

We can also test an app on a physical device. This requires connecting the physical device to the computer using USB cable and performing additional setup. See link below for details:

http://bit.ly/2rZTls1

It is a must to test an app on a physical device before releasing it as the emulator is only a simulation of a device and can not replicate all the internal workings of a physical device

23 of 30

Confirm Installation

  • Launch official emulator
  • In Android Studio, click on Run → Run ‘android_hello_world’
  • Wait for Gradle to build
  • App should eventually load in emulator window
  • You should now see the application running in the emulator!

Note: If this doesn’t run, try creating a new project instead with File → New → New Project and clicking “Next” and “Finish”

24 of 30

Git

Version control with Android Studio

25 of 30

Git -- Why?

When developing software, we should always use version control to manage our code.

Version control with Git is a way to backup our code, create a version history as we make changes and collaborate on code with other developers.

For our purposes, we will be using GitHub to store our code. GitHub is a free service for managing our code and saving a backup in the cloud.

We will also download and run our first Android application using Git.

26 of 30

Setup Git Client and Github

It is recommended to use the Git command-line tool. If you don’t have it, you can download it from https://git-scm.com/downloads

The course will be using Github to store projects. Setup your account on https://github.com

Learn basics of Git using:-

27 of 30

Clone HelloWorldDemo

In your terminal perform the following actions:-�

  • cd to the directory you want to download the sample project�
  • Run git clone https://github.com/codepath/android_hello_world.git

28 of 30

Import HelloWorldDemo

  • Switch to Android Studio and close any open projects.
  • In Android Studio dialog, select Open Existing Project...
  • In that dialog, find the android_hello_world project just downloaded.
  • Select build.gradle under the android_hello_demo path
  • Click "Ok" to Load the Project

29 of 30

Wrapping Up

Ensuring Setup is Complete

30 of 30

In Review

We have now finished setting up our Android environment including:

  • Android Studio IDE
  • Android SDK
  • Git
  • Setup Our First Android Application
  • Android Emulator