Android Studio Setup
Prepare your environment for Android
Overview
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.
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
Setting up Android Studio I
A newly installed Android Studio should now prompt you to use the wizard to setup the Android Studio.
Setting up Android Studio II
If installation succeeds, you should see the “Silent Installation Pass!” in “Show Details”�
Click “Finish”
Configure
Select “Configure”
and then “Preferences” in the bottom menu.
Configure Line Numbers
1. Find Editor → General → Appearance
2. Enable “Show line numbers”
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
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.)
Android Emulator
Running Android Apps in Android Studio
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.
Create Virtual Device
Select Create Virtual Device to add new virtual device
Setup Virtual Device I
Select Pixel as the device to run the Android OS on
Setup Virtual Device II
Select Recommended tab. Then select API 28. If you haven’t downloaded, click the Download link.
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
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.
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.
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.
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:
Don’t forget to save after making the change!
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
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:
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
Confirm Installation
Note: If this doesn’t run, try creating a new project instead with File → New → New Project and clicking “Next” and “Finish”
Git
Version control with Android Studio
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.
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:-
Clone HelloWorldDemo
In your terminal perform the following actions:-�
Import HelloWorldDemo
Wrapping Up
Ensuring Setup is Complete
In Review
We have now finished setting up our Android environment including: