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 IntelliJ IDEA which is faster and lighter than Eclipse.
When developing apps for Android, we will need Java SDK, Android SDK as well as the Android Studio IDE.
1. Android Studio
Installing Android Studio
Installing Android Studio
Download Android Studio which also includes an initial setup for Android SDK tools:
1. Download Android Studio
https://developer.android.com/studio/index.html
2. For OS-specific instructions, follow: https://developer.android.com/studio/install.html?pkg=studio
3. Launch Android Studio Application
Setting up Android Studio, 1
A newly installed Android Studio should now prompt you to use the wizard to setup the Android Studio.
Setting up Android Studio, 2
If installation succeeds, you should see the “Silent Installation Pass!” in “Show Details”�
Click “Finish”
Troubleshoot: Intel HAXM
In order for Intel HAXM to work, your computer must support virtualization. In some cases, computers support virtualization, but it is not enabled in the BIOS. In this case, when you try to install Intel HAXM, it will say something like:
"Your hardware supports virtualization, but it is not enabled. Restart your computer, navigate to your BIOS system settings and enable virtualization."
OSX machines usually have virtualization support already enabled.
For for information/help you can refer to https://developer.android.com/studio/run/emulator-acceleration.html
2. Studio Setup
Configuring Android Studio
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
Configure SDKs
Select “Configure”
and then “SDK Manager” in Menu
Android add-ons, 1
Click 'Apply' button once all versions are selected.
Android add-ons, 2
Check the following boxes:
Click 'Apply' button once all versions are selected.
3. Hello World with 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
4. 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.
There are two emulator options: Genymotion or Intel HAXM. We recommend using Genymotion if possible but requires at least 4GB of RAM.
Create Virtual Device
Select Create Virtual Device to add new virtual device
Setup Virtual Device - 1
Select Nexus S as the device to run the Android OS on
Setup Virtual Device - 2
Select x86 Images tab. Then select Nougat which you downloaded earlier as part of the SDK setup. If you haven’t then click Download next to the platform
Setup Virtual Device - 4
Select x86 Images tab. Then select Nougat which you downloaded earlier as part of the SDK setup. If you haven’t then click Download next to the platform
Setup Virtual Device - 5
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.
Confirm Installation
Note: If this doesn’t run, try creating a new project instead with File → New → New Project and clicking “Next” and “Finish”
Genymotion
Genymotion requires a few extra steps but is the current recommended Android emulator to use. See link below and next slides.
On PC’s: You must enable Virtualization Technology in the BIOS.
Genymotion, Installation
First steps in the Genymotion guide in the previous slide are:
Follow the guide above for the details.
Genymotion, Configure
Next steps in the guide in the previous slide are:
Follow the guide above for details.
Genymotion, Verify
Let’s verify our Genymotion setup by launching an emulator:
We’ll be using this emulator to test our app as we develop.
Testing on 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
Change default layout template
To make development easier, it is important to change the default template layout which is ConstraintLayout to RelativeLayout.
ConstraintLayout is a new UI layout that is considered to be more powerful and flexible than RelativeLayout but is not as mature so can have unexpected challenges.
By using RelativeLayout for now, it will make development easier. See the link below for details:-
The file is located in /Applications/Android Studio.app/Contents/plugins/android/lib/templates/activities/common/root/res/layout/
5. Wrapping Up
Ensuring Setup is Complete
In Review
We have now finished setting up our Android environment including: