Step 1. Install Oracle Java Development Kit ("JDK")
Since Android apps are written in Java, you will need the Oracle Java compiler and libraries on your system. These are collectively called the Java Development Kit or "JDK" for short. (If you already have JDK 1.6 or higher on your computer from taking CS 106A, you can skip to Step 2.) Download the JDK from the following address:
Java SE Downloads
Go to the page and click the DOWNLOAD link for the JDK. Click the radio button to accept the License Agreement, then download the appropriate JDK for your operating system. For example, on Windows, click to download the "Windows x86" installer.
(A common mistake here is to accidentally download the Java Runtime Environment, or "JRE", instead of JDK. The JRE is not the right download; JRE enables you to run Java programs but not compile or develop your own. Be careful to download JDK and not JRE.)
The next piece of software for you to install is called Android Studio. This is an official text editor and integrated development environment (IDE) for developing Android apps. You must install Oracle JDK before installing Android Studio, so please don't start this step until you have completed Step 1 above.
Download Android Studio from the following address:
Android Studio Download Page
Once you click the Download link, you will be asked to accept a license agreement. Then you will be able to download the software. The download may take a while because the file can be almost 1gb in size.
Once you have downloaded the installer, run it to install Android Studio on your computer. The installation make take a while because of all the components and libraries included. You can choose all of the default settings during the installation.
(Mac OS X only)If you are using a Mac, your computer might try to block the Android Studio installation. You might see a warning that says, "The package is damaged and should be moved to the trash." If your OS is blocking the installation, go to System Preferences > Security & Privacy and under "Allow applications downloaded from", select Anywhere. Then try to open Android Studio again.
(Windows only) If you are using the Windows operating system, you should also download and install the following USB driver pack. These USB drivers will help you to deploy apps to your phone or tablet from your computer.
Windows USB driver download page
If you need more information, see Google's Android page on installing Android Studio:
Android Studio - Installing
Step 3. Configure Android Studio
Once Android Studio is installed, we'll need to configure a few important settings and install a few extra features. First, launch the Android Studio application. This may take a while, as the app needs to complete the installation and initial configuration, as well as downloading and applying any updates.
(Mac OS X only) If you are using Mac OS X Yosemite and the latest Java v1.8, your computer might be unable to launch Android Studio. If so, open the application package for Android Studio in your Finder, and edit the Info.plist file. Change the key JVMversion to store the value 1.6+ instead of 1.6*. For more info, see this thread on StackOverflow.
Once Android Studio is running, you will need to load the "SDK Manager" menu. This is found by clicking the following icon in the top toolbar:
The SDK Manager window has a series of nested checkboxes to allow you to install various packages and features. The overall list has categories such as Tools, Android 5.0.1, Android 4.4.2, Extras, etc. These represent various versions of Android that could be installed on your system. Click the first of these categories. (As of this writing, that is "Android 5.0.1 (API 21)". Under that category, check the box for "Intel X86 Atom System Image". We will need this in order to run the emulator. (Windows only) Also go to the Extras category and check the box for "Intel x86 Emulator Accelerator (HAXM installer)".
Once you've selected all the desired packages, Click the Install X packages button at bottom-right. In the next window, you will need to accept the license agreement for each installed package. Once you do so, click Install, and the packages will be downloaded and installed for you. Wait until the packages are finished downloading and installing before proceeding. (Wait for the screen to say "Done loading packages." at the bottom.)
To run your Android apps on your computer, you can use a "virtual device" which is a software emulation of an Android phone or tablet. In past versions, you needed to set up this virtual device yourself. But if you install the current version of Android Studio with the default settings, it automatically creates a "Nexus X" device for you, so you don't need to do anything here. Hooray!
If you need more information on this step, see Google's Android page on virtual devices:
Android Studio - Managing Virtual Devices
Step 5. Make and Run a "Hello World" Project
You're basically done now, but let's make sure everything is running properly by creating and running an empty "Hello World" project. Load up Android Studio and click "Start a new Android Studio project". (If this is your first time ever running Android Studio and creating a project, you may need to Accept the license agreement.) You can use all of the default settings and names for your project. In particular, when you get to the "Add an activity" screen, just choose the default "Blank Activity" option. Click Next and Finish on each screen until the project is created.
Once the project is created, you should see a Design view with a palette of widgets and a preview image that looks like an Android device. You don't need to edit any code or anything yet.
Click the "Play" button icon in the top toolbar to run the app: Once you do this, it will ask you what virtual device you want to use. You can choose the default virtual device that was created during installation. (Ours is called "Nexus 5 API 21 x86".)
If you get the following error at this point:
emulator: ERROR: x86 emulation currently requires hardware acceleration! Please ensure Intel HAXM is properly installed and usable. CPU acceleration status: HAX kernel module is not installed!
There are two ways to fix this error. The first fix is to enable hardware acceleration by following Google's instructions for configuring VM acceleration. This is the preferred fix if possible. If that fix does not work, you can instead change your VM to use the ARM CPU mode rather than x86. Unfortunately, changing your VM to ARM mode will make the VM run very slowly because it is not hardware accelerated.
To change your VM to ARM mode, click the AVD Manager icon at the top of Android Studio: Then you should see your default Nexus device. Press the "pencil" icon on the right side to edit the device's configuration. In the configuration screen, in the area for the android version Lollipop, at right click Change. In the window that appears, select a row where the "ABI" starts with "arm", such as "armeabi-v7a". Then click Next/Finish to get back to Android Studio.
When you try to run the app on your virtual device, sometimes the device just sits at the device's home screen rather than automatically running your app. If this happens, click the bottom-right button in the virtual device, the one that looks like a 3x3 phone keypad. This should pop up a list of all apps available. Find your app in the list and click it to run it.
If you need more information on this step, see Google's Android page on creating a first project: