Note that the latest version of Android Studio is vastly different from any previous version and this prompted the author to rewrite this 'how-to'. It must be pointed out to new users that the Android Studio is now based upon the JetBrains's IntelliJ IDE – which is vastly different from the Eclipse IDE on which the previous Android Studio is based. So new users are encouraged to read about the IntelliJ IDE before using it. Note also that this a revised 'how-to' with all the unnecessary steps removed. There are also more screen shots to explain things graphically.
Before we start off on our journey, I will assume that you have installed the latest version of Windows 10 and apply all the latest updates for the PC. Also, note that I will assume that you have installed the proper propriety video drivers for your PC. Note that this 'how-to' is based on an AMD video card equipped PC, with the propriety video driver installed. In my previous 'how-to', I mentioned that AMD video card, with the propriety video driver installed, will cause problems with Android Studio, especially when trying to run an emulated Android Virtual Device (AVD). This issue is no longer true – the manufacturers have solved this problem and the result is that it does not matter which video card is used – Nvidia, AMD or Intel – the end result is the same. This means that anyone can use Android Studio with a video card from Nvidia, AMD or Intel.
This 'how-to' was tested on the following hardware and found to be working:
- Gigabyte GA-Z77-HD3 Motherboard
- Intel Core i5-3470 CPU (3.2 GHz)
- Kingston 8 Gb DDR3 HyperX RAM
- AMD/ATI Radeon HD 5770 PCI-E Graphics Card
STEP 1: Install Oracle's Java JDK (or SE) 8
On a newly-installed Windows 10 PC, there is no Java installed by default. This can be verified by opening a terminal by right-clicking on the 'Start' button and selecting the 'Command Prompt' or 'Windows PowerShell' (if you are using the latest Windows 10 Creators Update, then follow the instruction here to re-enable the Command Prompt if you like). Then execute the following command:
If you see a response similar to the figure below (shown for the 'Command Prompt' only), then you can be sure that there is no Java installed.
NOTE: If you are using a Windows 10 PC with Oracle's Java JDK 8 already installed, except it's an older version, then you need to update it. The update process is covered later in this 'how-to'. Note that if you already have the latest version of Oracle's Java JDK 8 already installed, then you can safely skip the part on downloading and installing Java.
You can then proceed to install Oracle's Java by pointing your web browser to here and clicking on the 'Download' button as indicated by the green arrow in the figure below. Note that the web page image is cropped to accommodate this 'how-to'.
NOTE: The current version (as of July 2017) of Java JDK (or SE – they are the same) is 8u144 but the version number shown may be higher than this as Oracle is constantly updating Java. The 8u144 version is highly recommended here of course unless you have a specific need for a particular version (scroll down and click on the 'Download' button for the 'Java Archive' if this is the case). In general, always choose the highest version of the JDK to download. Updating will be covered in detail in a later section.
On the next page that appears, you will find an item labeled 'Java SE Development Kit 8u144'. On this item, click on 'Accept License Agreement' as indicated by the green arrow, and followed by a click on the Windows x64 Java download file also as indicated by the green arrow (see figures below). Remember to save the files if a prompt appears – they will go into the 'Downloads' folder by default (unless you have changed this location).
On the same page (you may have to scroll up a bit), you will find an item labeled 'Java SE Development Kit 8u144 Demos and Sample Downloads'. On this item, click on 'Accept License Agreement' (see below), and followed by a click on the Windows x64 Java download file as indicated by the green arrow (see below). Remember to save the files if a prompt appears – they will go into the 'Downloads' folder by default.
NOTE: Strictly speaking, this item is not necessary for Android program development but is recommended if you are new to Java and wish to play around with demos and samples provided by Oracle.
Now click the 'Back' button on your web browser and then locate and click on the Java SE 8 Documentation 'Download' button as indicated by the green arrow in the figure below (you may have to scroll up a bit to see this item). This is required in order to download the API documents for Java. This item is strictly not necessary for Android program development but is highly recommended if you are a heavy Java programmer.
On the next page that appears, click on 'Accept License Agreement' as indicated by the green arrow, followed by a click on the document download file also as indicated by the green arrow (see figure below). Remember to save the files if a prompt appears – they will go into the 'Downloads' folder by default.
If you take a look in the 'Downloads' folder (see below), you should see the following 3 files (if you have downloaded all 3):
To install the Java JDK 8, double-click on the 'jdk-8u144-windows-x64.exe' file. The User Account Control (UAC) may appear next. Click on 'Yes' and if you are prompted for a password, supply one. The 'Java Setup' window as shown below will appear.
From here, follow the on-screen instructions in order to install Java – keep clicking on the 'Next' button when they appear, until you come to the last window where you can click on the 'Close' button (see figures below). Oracle Java is now installed on your PC.
If you have downloaded the demos (and samples) and docs, now would be a good time to install them. First, unzip the demos to a temporary directory (any will do) – this will create a 'jdk 1.8.0_144' sub-directory in which there will be two more sub-directories – 'demo' and 'sample'. Then unzip the document file to the same 'jdk 1.8.0_144' sub-directory just created. This will create another sub-directory called 'docs'. The process may take some time to complete, so be patient. The final files will look like the figure shown below.
Then click on the 'jdk 1.8.0_144' temporary directory and move all these 3 sub-directories ('demo', 'docs' and 'samples' – without the 'release' file) to the actual Java directory, i.e., 'C:\Program Files\Java\jdk1.8.0_144'. You will have to give permission for this action since you are moving files into a 'system' type directory. You can now delete the remaining temporary folder (which should contain one file – the 'release' file) from the temporary directory.
NOTE: Do NOT move the directories into the JRE folder. Note that the JRE folder is present in the actual Java directory, i.e., 'C:\Program Files\Java\' in this case.
One more thing before going any further and that is to first set the JAVA_HOME environment variable and to set the PATH environment to include the 'bin' directory of where Java was installed on your system. If you have not changed it this would be 'C:\Program Files\Java\jdk1.8.0_144'. To do this, right-click on the 'This PC' icon on your desktop and select 'Properties'. Alternatively, if you have not personalized your desktop and 'This PC' icon is not present on your desktop, launch 'Windows File Explorer', then right-click on the 'This PC' item in the 'File Explorer' and select 'Properties'. A window similar to the one shown below will appear.
On that window, click on the 'Advanced system settings' item. On the 'System Properties' window that appears (see figure below), click on the 'Environment Variables...' button.
The 'Environment Variables' window will appear (see figure below). Under the 'System variables' part, click on the 'New...' button.
The 'New System Variable' window will appear (see figure below). Enter 'JAVA_HOME' as the variable name and 'C:\Program Files\Java\jdk1.8.0_144' as the variable value as shown in the figure. Then click the 'OK' button. You will find the new 'JAVA_HOME' environment variable listed in the window (see below).
If you look at the 'System variables' portion of the window, you see the 'Path' item. Click on it as shown in the figure below.
Click on the 'Edit...' button. The 'Edit environment variable' window will appear (see figure below).
Click the 'New' button, then type 'C:\Program Files\Java\jdk1.8.0_144\bin\' into the next blank available field which will appear. Then press the 'Enter' key. The completed screen will look something like this:
NOTE: You will find an entry 'C:\ProgramData\Oracle\Java\javapath' already present in the PATH environment – do NOT delete or do anything to this variable – it is managed by Oracle.
Click 'OK', followed by another 'OK', and finally another 'OK'. Then close the Control Panel. To make the new environment variables effective, log out of the system, then log in again. Open a non-admin command prompt (the commands 'echo' will only work for a command prompt) and type the following commands (followed by the 'Enter' key), one by one:
You should see something similar to the window below, i.e., the string '1.8.0_144' should be part of the output.
NOTE: Strictly speaking, the JAVA_HOME and PATH settings are not necessary for Android program development but is recommended if you are new to Java and wish to learn Java programming, which is a requirement for Android program development. The JAVA_HOME and PATH settings will help the new Java programmer to execute the 'javac' (the Java compiler) from anywhere in the system.
STEP 2: Install Android Studio
Now it's time to download and install Google's Android Studio. Point your web browser to here and click on the big green button to start the download.
Then place a check mark accepting the terms and conditions of Android Studio and then click the download button. Save the file and wait for the download to finish.
NOTE: The downloaded file is named 'android-studio-bundle-162.4069837-windows.exe' and is the currently the latest version of Android Studio (as of July 2017). The version number shown may be higher than this as Google is constantly updating it. As usual, it is highly recommended that you use the latest version.
Open Windows Explorer and go to the 'Downloads' folder. Double-click on the downloaded file to install it – if the User Account Control (UAC) window appears asking for permission, click on 'Yes' to allow Android Studio to be installed on your PC. The downloaded file will then start installing and the setup window (see figure below) will appear. Click on the 'Next' button to proceed.
The next window is where you select the components to install. Note that they have been preselected to install all components – unless you have a need, do not deselect any components and click 'Next'.
The next window (shown below) is the license agreement for Android Studio. If you agree to the terms of the agreement, click on the 'I Agree' button to proceed.
The next window (shown below) is the configuration settings where all the installation paths are shown. Change it if you wish, but for this 'how-to', keep it as it is and click the 'Next' button to proceed.
The next window is the creation of a start menu folder – leave it at the default and click on the 'Install' button.
The actual installation of Android Studio will begin as shown below. This may take some time to complete so be patient.
Wait for the installation to finish and the window shown below will appear. Click on the 'Next' button.
The last window (shown below) will be displayed with the 'Start Android Studio' checked – keep it as it is. Click the 'Finish' button to close the setup window and start Android Studio.
The first window (shown below) asks whether you want to import any settings. If this is the first time you installed and started Android Studio, chances are that you don't have any – so just click on the 'OK' button. Of course, if you had installed Android Studio on Eclipse previously and wish to preserve the settings on Eclipse, feel free to import the previous settings by following the on-screen instructions.
Android Studio will begin loading as shown in the figure below.
The 'Setup Wizard' for Android Studio will start and the first window (the welcome screen) will look like the one shown in the figure below. Take time to read the text and then click on the 'Next' button to proceed.
The 'Install Type' window will appear next as shown below. The 'Standard' type of setup is already preselected – unless you have a need to customize the setup (click on the 'Custom' item), click on the 'Next' button.
The 'Verify Settings' window will appear next as shown below. If you need to change anything, click on the 'Previous' button and select 'Custom' item – else click on the 'Finish' button.
The 'Downloading Components' window will appear next as shown below. If components need to be downloaded and installed, Android Studio will do so (this may take time so be patient) – else it will display a window with the message 'Android SDK is up to date' (where SDK stands for Software Development Kit) as shown in the figure below. Click on the 'Finish' button to close the Setup Wizard.
Android Studio will start and the initial IDE will appear as shown below.
Take some time to inspect the welcome screen of Android Studio. If you are new to Android Studio and Android programming, you should concentrate on the first item in the menu – the 'Start a new Android Studio project'. If you had created a project, you may use the 'Open an existing Android Studio project' menu item. The rest of the menu items are for advanced users – i.e., Version Control, importing projects and Android code samples.
Note the two items on the bottom of the Android Studio window – the 'Configure' and 'Get Help' items. The 'Get Help' item is self-explanatory – it allows you to seek help from Google (the User Manual!) or IntelliJ. It also allows you to check/set the 'Tip of the Day' settings.
The 'Configure' item allows you to carry out various configuration to Android Studio – specifically to the SDK Manager, the default Android Studio Settings, the default Android Studio Plugins, and Import/Export Settings. It also allows you to check/set the Settings Repository, Check for Update and finally, check/set Projects Defaults. If any of these terms seems to be gibberish to you, then do a Google search for them.
NOTE: The latest version of Android Studio 2.3.3 has a new look which differs from the previous versions. One of the major differences is the way Android Studio 2.3.3 handle updates – if there are any, the last line on the IDE window will contain an additional item – the 'Events' item with a green balloon to the left. Click on the 'Events' item, then on the 'update' item (you may have to do this twice) and follow the on-screen instructions if you wish to apply the updates. Note that the update message may also appear in the projects window – as before, click on the 'update' item and follow the on-screen instructions if you wish to apply the updates. Updating will be covered in detail in a later section.
STEP 3: Configuring SDK Manager
To start configuring Android Studio for this 'how-to', click on 'Configure' item then select the 'SDK Manager' (see below).
The 'Default Settings' window will appear as shown below.
Note that the 'Android SDK' item is automatically selected on the left pane of this window. Other items are listed in the left pane and are available for you to use, but for the time being, keep the selection on the 'Android SDK' only in the left pane.
The column to note is the 'Status' column – it is where the window indicates whether the package has been installed or any updates are available for any package. For the purpose of this 'how-to', a 'package' can include other packages – but this window will only show the 'main' package.
The location of the 'Android SDK' is clearly stated on this window, and you can change its location if you wish – but for the purpose of this 'how-to', keep it as it is.
Note also that the tabs below the SDK location are preselected for the 'SDK Platform'. To change tab, all you need to do is to click that tab – for example, click on the 'SDK Tools' tab, and you will see the contents of that tab (see below). Note the item 'Intel x86 Emulator Accelerator (HAXM Installer)' which is marked as 'Installed'. Make sure that this item exists and is installed on a Windows 10 PC – else you may experience problems with the emulator later.
NOTE: There are lots and lots of SDK tools listed here. Only those tools that are essential to initially build a project have been installed. You are free to install any other extra tools as you so wish.
If you see any items with a minus sign instead of a check mark and you see the text 'Update Available: xx.x' (where x can be any number), then it is advisable to apply the update immediately. To do this, click on the minus sign beside the items and note the 'Download' icons that appear for the selected items. Then click on the 'Apply' button, followed by a click on the 'OK' button on the 'Confirm Change' window that pops-up (see below). On the 'License Agreement' window that appears next, click on the 'Accept' button, followed by a click on the 'Next' button (the 'Component Installer' window will appear as shown below). Wait for the component to be downloaded and installed. Then click on the 'Finish' button (see below). You will be back at the 'Default Settings' window with the tab at 'SDK Tools' (see below). Check if the settings are correct and that there are no more available updates to be applied.
If you click on the 'SDK Update Sites' tab, you will see URL's for the sites (see below) – do not change anything on this window at this time. Now click the 'SDK Platform' tab again – keep it at that tab for the moment.
Note the 'Show Package Details' box at the bottom of the window – at the moment it is not selected (i.e., no check mark has been placed there). Click on the box to select it – the display will change as shown below.
This display window will show more details on the packages installed so far – including their API level, its revision number and as mentioned previously its status. Note that it even includes packages for Android 8.0 (codenamed O).
Based on your requirements, you may decide to install more packages – for example, the author has a Google/LG Nexus 5X smart phone running on Android 7.1.2 (Nougat) – so it was decided to install the additional packages as shown by selecting the box next to its names. Note the 'Download' icons that appear as soon as you select the boxes for the items (see below).
NOTE: If you decide to use the latest Android 8.0 (codenamed O), do so as the latest Android version is backward compatible.
You are free to select any packages to download and install, depending on your actual Android devices that you possess. Note that I have personally selected to download both the 32-bit and 64-bit versions of Intel Atom x86 and Google API system images, though you may do otherwise. Just select them (you have to scroll down the display for more packages), then click on the 'Apply' button and the 'OK' button on the 'Confirm Change' window that appears next, followed by the 'Component Installer' window (see below).
NOTE: If you deal with Android TV and/or Android Wear, make sure that you download these items.
The ARM system image more closely matches most Android devices using these processors, but requires the processor to be emulated and is thus very slow. The Intel x86 Atom system image is potentially quite a bit faster, using the Intel HAXM virtual machine support mechanisms to execute the code in a partially native way. You can try the x86 for speed, and fallback to the ARM if you have compatibility problems.
Support for Google specific Android APIs like the Android Google maps API, are not provided with the standard Android system images. They need to be installed separately using the SDK manager. To use these APIs with an x86 system image you need to also install the Google APIs (x86 System Image) for the same API level.
The difference between a 32-bit and a 64-bit processor is self-evident and can be found easily on the Internet. Examples can be found here or here.
Note that the Google APIs appear on the Android 7.0 (Nougat) line – do not clear (or delete) this item.
Wait for the download to finish (it may take some time to complete), then press the 'Finish' button (see below).
You will be back at the 'Default Settings' window of the Android SDK (see below). Inspect the packages that were downloaded and installed to make sure that they are correct. If any errors are found – such as downloading errors – then try again. Once this is successful then click the 'OK' button.
You will be back at the welcome screen of Android Studio. Click on 'Configure' again, followed by a click on 'Project Defaults', and finally on the 'Project Structure' item (see below).
On the 'Project Structure' window that appears next (see below), note that Android Studio has been preset to use an embedded Java JDK (the JRE portion). You can continue using this embedded JDK without any problems. However, if you have installed the latest Oracle Java JDK (which you have), you may wish to switch to that instead.
To do that, we first have to clear the box as shown in the figure below. Note that a message will appear at the bottom of the window telling us to 'Please choose a valid JDK directory'.
To select a valid JDK directory, click on the button with three dots (or period) to the right of the field – the screen will change to a directory picker. Navigate to the Java JDK directory as shown below, then click the 'OK' button.
NOTE: On the same screen you will find the field where you can specify the Android NDK (which stands for Native Development Kit) location. Keep this field blank as we are NOT using this feature.
Click the 'Apply' button. If this setting is acceptable to Android Studio, no messages will be shown. Then click on the 'OK' button (see below).
NOTE: If you have updated Oracle's Java, remember to set the JDK location to the new version. Do this if you decide to delete the older Java version from your PC.
You will be back at the welcome screen of Android Studio (see below). Close Android Studio by clicking on the 'x' (as indicated by the green arrow) on the top right hand of this window.
Before you do anything else, you need to place a launcher for Android Studio in your Windows 10 taskbar in order to make it easier to start. Click on the 'Start' icon and locate the 'Android Studio' item. Then right-click on the 'Android Studio' item (see figure below), then click on 'More' item. Then you can pin 'Android Studio' to the taskbar by clicking on the 'Pin to taskbar' item. You can also place an icon on your desktop by clicking on the 'Open file location' item. A Windows Explorer window will open showing the file 'Android Studio'. Create a shortcut for this item on your desktop and then close the window.
STEP 4: Create a New Project Using Android Studio
Now that you have successfully installed Oracle's Java JDK and Google's Android Studio, it's time to use Android Studio to develop software for the Android platform. We start off by using Android Studio to write a short and simple 'Hello World' program, which you can run either on your Android Virtual Device (AVD), or your actual Android device.
Use either the icon in your taskbar or on your desktop to launch Android Studio if it is closed. Start a new project by clicking on the 'Start a new Android Studio project' (as indicated by the green arrow) item from the welcome screen (see below).
The 'New Project' window as shown below will appear – fill in the details for the 'Application name' to 'Hello World' and 'Company Domain' to 'any.company.com' as shown. The directory in which this project reside can be anywhere on your PC. In the example shown, I have placed the project in my home folder's 'Projects/Android' directory (see below) but you are free to use any directory you wish. Then click on the 'Next' button.
NOTE: You can change the package name by clicking on the 'Edit' button on this window – but I suggest that you keep this package name – at least for this 'how-to'. Likewise, you can also enable C++ support by enabling the appropriate box – but for this 'how-to', leave it off.
The 'Target Android Devices' window will appear next (see below). Make sure that the 'Phone and Tablet' item is selected as the 'Hello World' project application (or app for short) is meant for an Android smart phone. The 'Minimum SDK' is preselected to be 'API 15: Android 4.0.3 (IceCreamSandwich)' and the reason why is as stated in the note below this field. If you are unsure on which minimum SDK to select, you can click on the 'Help me choose' item. For this 'how-to', leave it at the preselected minimum SDK. Then click on the 'Next' button.
NOTE: If you are developing any projects for Android Wear and/or TV, then select the appropriate buttons. The Android Auto item enables you to add support for it to your existing app. It will enable your app to work on both car and phone screens. Android Auto handles most of the work to adjust each application's user interface to the screen on which it is displayed. Note that to enable your app for Wear/TV/Auto, your app must target Android 5.0 (API level 21) or higher.
The 'Installing Requested Components' window will appear next (see below). Wait for the downloads to finish. When all the components have been downloaded and installed, click on the 'Next' button. Note that this window will only appear if there are components or packages to download and installed – else this step will be skipped and the 'Add an activity to Mobile' window will appear next.
The 'Add an activity to Mobile' window will appear next (see below). Select the 'Empty Activity' item if it is not preselected. Then click on the 'Next' button.
NOTE: There are lots of activities to choose from – you can scroll through the available ones and pick one to suit your app. According to Google, activities are one of the fundamental building blocks of applications on the Android Studio platform. They also serve as the entry point for your interaction with an application and are also central to how a user navigates within an application or between applications. For further reading, go here.
The 'Customize the Activity' window will appear next (see below). Change the 'Activity Name' to 'MyActivity' and the rest of the items below will change as shown – this serves to illustrate the interactions between these two items. Then click on the 'Finish' button.
NOTE: There are two other radio boxes that you can use – one is labeled 'Generate Layout File' and the other is labeled 'Backwards Compatibility (AppCompat)'. The 'Generate Layout File' allows you to generate an XML file for the activity, while 'Backwards Compatibility (AppCompat)' is letting you know that if you uncheck it, then you'll be including and using the library Activity instead of AppCompatActivity. At the moment, both of these are enabled (i.e., they both have check marks). Leave them enabled for the time being. Use Google to search for more information on these items.
Android Studio (the 'Gradle' part anyway) will then start building the project as shown below – this may take some time to complete so be patient. Note that, if a Windows 10 Security Alert window should pop up, click on the 'Allow Access' button to allow Android Studio access through the firewall.
Note that the project is a basic 'Hello World' app that contains some default lines so you do not have to enter those lines into the project. Later you can view the Java source code for this project in the Android Studio IDE.
When completed, Android Studio will display its main IDE window. If a 'Tip of the Day' window appears (shown below), you can safely close it by clicking on the 'Close' button. You can, if you wish to, also clear the box labeled 'Show Tips on Startup' to disable this feature. Also, if a Windows Security Alert should pop-up (also shown below), click on the 'Allow Access' button to grant access to Android Studio through the Windows firewall.
If this is the first time you are using Android Studio, the next screen will take some time to appear while the system will carry out indexing of the IDE – the word 'Indexing...' will appear in the bottom of the IDE window (see below).
After the system has finished indexing, a window similar to the one shown below will appear.
NOTE: For those users who are new to Android Studio (and the IntelliJ) user interface, the various buttons, menu items, tabs, etc, poses a very big challenge – for example, what are the purpose of the various buttons? Do not despair as the Android Studio User Manual is available online here. They will help you to familiarize yourself with the various parts of the IDE. For those who are interested, a guided tour around the IntelliJ IDE user interface (on which the Android Studio is based) is also available here. Take some time to familiarize yourself with the functions of the various components of the IDE. For those of you who are familiar with a programming IDE, you can safely disregard this note and proceed with the 'how-to'.
If any error occurs during the project build, Android Studio will display the error message and will offer a 'Tip' to try out ways of solving it. As an example, the error message shown below may pop-up on the bottom of the editor. Check the tip message and then click on the 'refresh' item – the screen will refresh and the error message may disappear – if not, try again.
Notice that the graphics shown is a Nexus 4 device. If this is acceptable to you, then don't change anything. However, since the author has a Nexus 5X device, it was decided to change the graphics to show such a device. This can be achieved by simply clicking on the downward pointing arrow beside 'Nexus 4' (as shown by a green arrow in the figure below), and then selecting 'Nexus 5X' from the drop-down list (see below also). Of course, you are free to choose any other Android device from the list depending on the actual device in your possession. Note that there will be no change in the graphics shown (see below) since the 'Nexus 4' device is similar to that of 'Nexus 5X'.
Now that we have created a new 'Hello World' project, we will test it out to see whether it will run as advertised. Before we do this, we need to create either an emulated Android device or use an actual Android device. We will now proceed to create an emulated Android device for testing the project. Later, this 'how-to' will describe the procedure for running the project on an actual Android device.
STEP 5: Create Emulated Target Android Device
If you have closed Android Studio, launch it again and make sure that the 'Hello World' project is on the screen. Notice in Android Studio's toolbar an icon with some words in it. Hover the cursor over the icon and you will see 'AVD Manager' – that is the icon I am referring to – then click on it (see below). Alternatively, click on 'Tools' in the menu, followed by a click on 'Android' and finally on 'AVD Manager' (see below also).
No matter which path you took to activate the AVD manager, the window will change to 'Your Virtual Devices' as shown below. If you are running Android Studio for the first time, no virtual devices have been set up and the '+ Create Virtual Devices...' button will be shown. Click on that button.
The 'Select Hardware' window will appear next (see below). It already pre-selects the Nexus 5X device with the specifications shown. Note the 3 buttons at the bottom of the window. The 'Hardware Profile' button allows you to create an Android device other than that in the list. The 'Import Hardware Profiles' allows you to import a profile stored on your PC into Android Studio. The 'Clone Device...' button allows you the clone the currently selected device (the Nexus 5X in this case), and use this as a base for a new device similar to the Nexus 5X. For the time being, do not press any of the 3 buttons – instead just press the 'Next' button to proceed.
The next 'System Image' window is where you specify the 'System Image' to use for the AVD. The 'Recommended' tab is already selected and the cursor is already resting on the recommended item (see below), which is 'O – API 26 – x86 – Android 8.0 (Google Play)' – which does not meet my requirements. According to which Android device I possess – a Nexus 5X – I would require a Nougat-based x86 emulator with API 25. It must be compatible with Android 7.1.1 (and above) and must use Google APIs.
Note that there other tabs – the 'x86 Images' and the 'Other Images' tabs. These allow you to select other images to use (you have to download and install some of these before they can be used).
You may notice that a 'Recommendation' message which will appear on the right side of the window. This message states that 'HAXM is not installed' (in red color) and a clickable item which that states 'Install Haxm' (in blue color) will also appear. This is in contrast to the fact that HAXM is stated to be installed in the SDK Manager. Anyway, click on the 'Install Haxm' item to install Intel's Hardware Accelerated Execution Manager (HAXM). For those interested in learning more about HAXM, open a web browser and click here for details.
The User Account Control (UAC) may appear next. Click on 'Yes' and if you are prompted for a password, supply one.
The window will then change to the one shown below. In this 'Emulator Settings' window, you can specify the amount of RAM to use. Unless you have a need, leave it at the recommended size and click on the 'Next' button.
The HAXM installer will then start to install as shown in the 'Invoking installer' window below.
Wait until the installer has finished (see below), then click on the 'Finish' button.
You will be back at the 'System Image' window. Note the 'HAXM is not installed' message – although you have just installed it, this message will still appear – perhaps a Google bug?
Now click on the 'x86 Images' tab and select 'Nougat – API 25 – x86 – Android 7.1.1 (Google APIs)' – if this is not already selected. Note that this is to suit my Android smart phone (a Nexus 5X), but you can select any other Android device if you so wish. The window will look something like the one shown below. Then click on the 'Next' button.
NOTE: The 'HAXM is not installed' message on the 'System Image' window will disappear if you restart Android Studio and create a new AVD.
The 'Android Virtual Device (AVD)' window will appear next. Note that you can change (if you wish) some things on the window. For example, if you wish to change the name of the AVD all you have to do is to click anywhere on the field and make the changes. You can also change the AVD device and/or the Android OS by clicking on the 'Change' button. The Startup Orientation is also changeable – portrait or landscape mode. Likewise the Emulated Performance and Device Frame.
You can also click on the 'Show Advanced Settings' button for more settings to set and configure. This button will reveal the Camera (Front and Back), the Network (Speed and Latency), the multi-core CPU, the Memory and Storage, the Custom skin definition, and the Keyboard settings. You can change any of these settings if you so wish.
Verify all the settings (see below) – then click on the 'Finish' button.
You will be back at the 'Your Virtual Device' window (see below) with the newly-created AVD listed. From here, you can either launch the AVD, edit any AVD settings and perform any other actions by clicking on any icons in the 'Actions' column. You can also define a new AVD by clicking on the '+ Create Virtual Device...' button (as an exercise, try creating a 64-bit version of the same AVD). For now, close this window via the 'x' on the top right-hand corner and you be back at the project window.
STEP 6: Running The Project On The Emulated Target Android Device
On the Android Studio project window's toolbar (below the menu bar), there will be a green-coloured icon that looks like a right pointing arrow (see below). If you hover the cursor over the icon, the words 'Run 'app' (Shift F10)' will appear.
Click on the icon (or press the Shift F10 keys) and the 'Select Deployment Target' window will appear (see below). Note the warning message (on a yellow background) stating that 'No USB devices or running emulators detected'. You can safely ignore this message – you have not connected an actual Android device and the emulator has not started yet. Also, note that the Nexus 5X emulator (which you have just created)) has been preselected by default. You can set this AVD as the device that will be selected in future by clicking on the box labeled 'Use same selection for future launches'. Note you can also create a new virtual device by clicking on the appropriate button. Now click on the 'OK' button.
The Nexus 5X AVD will start by displaying a small 'Android Emulator' window, and after a while, the AVD will appear displaying the flashing 'Android' sign (see below).
NOTE: If you see an 'Instant Run applied code changes and restarted the app.' message on a green-coloured background (shown below) on the project window, click on the '(Don't show again)' item to make it go away permanently.
Then the AVD will display the home screen for a short while (see below), after which 'Hello World!' will appear on the AVD's screen (see below). This means that the Nexus 5X AVD is set up correctly and is working perfectly. Note that 'Hello World!' will appear at the center of the AVD's screen. This differs from the previous versions of Android Studio where the message was placed at the beginning of the screen.
Note the small vertical window to the right of the AVD (see below). This contains all the controls for the AVD – which includes the power button, the speaker volume controls, the screen rotation controls, the camera button, the search button and the navigation buttons. Try them out. At the extreme top are the minimize and exit buttons. At the extreme bottom is a row of three horizontal dots – clicking on this will bring up another window (shown below) where more extended controls are located. You can play with the controls if you wish.
NOTE: The extended controls allow you to set several parameters such as Location (GPS), Cellular network, Battery level, Phone/SMS calls, Directional pad (useful on a tablet), a Microphone device, Fingerprint device, Virtual sensors (accelerometers, etc), Settings, and lastly, Help.
When done, click on the 'x' located at the top right of this window to close it. To close the AVD, click on the exit button located on top of the control window (looks like an 'x'). You will be back at the project window as shown below.
In order to test the Nexus 5X AVD, first, you have to run the project again by clicking on the 'Run' button on the project window. Then close the 'Hello World' project on the AVD. This can be done easily by clicking on the 'Back' icon on the AVD (see below where the icon is indicated by the green arrow) and the screen will change to one as shown below.
This is the 'Home' screen of the Nexus 5X AVD. Users familiar with Android smart phone may be wondering 'where is the app icon?'. Just remember that this the Nexus 5X AVD running Android version 7.1.2 – it's a bit different from the usual Android where the 'app' icon is present on the home screen. To see all the apps on the AVD, click on (or drag it upwards) on the 'arrow' icon as indicated the green arrow. The apps will be shown on screen (see below). You can try the apps by clicking on them. Note that for some apps, you need to sign in first, then sync the app with your phone data.
To dismiss the app screen, press the back button. Alternatively, from anywhere below the 'Search Apps' line, drag downwards with the cursor. The 'Home' screen will reappear.
Now click on the 'Google Chrome' web browser icon (as indicated by the green arrow below). If your PC is connected to the Internet, you should see a screen similar to the one shown below. This is the welcome screen for Google Chrome – click on the 'ACCEPT & CONTINUE' button to proceed. Next, you will see a sign-in screen – you can either sign-in or decline – that decision is up to you (I clicked on the 'NO THANKS' button).
Next, you will see the Google web page with a search field prominently displayed (see below). Then click on the empty field and, using the on-screen keyboard, type in 'microsoft' and press the 'Enter' key on your PC's keyboard. Scroll down the AVD's display to see all the possible matches to your search (see below). An example of the web page is as shown below when the first search result is clicked on.
To go back to the home screen, press the 'Home' icon (the circular one at the bottom as indicated by the green arrow in the figure below) on the AVD. To close the AVD, click on the 'x' on the vertical panel on the right. You will be back on the 'Projects' window.
You can close the 'Hello World' project any time by clicking on 'File' menu and selecting 'Close Project'. Then you can close Android Studio if you wish. Alternatively, if you want to keep the 'Hello World' project (or any project) in the project window on the next restart of Android Studio, all you need to do is to click on the 'x' on the top right-hand of the project window. You need to confirm this exit by clicking on the 'Exit' button.
STEP 7: Running The Project On An Actual Target Android Device
We have successfully tested the 'Hello World' project on the AVD emulator. However, our ultimate goal is that the project should run on an actual Android device (a smart phone, for example). In order to do this, you need to connect that device to our development PC (the PC on which Android Studio is currently running) using a proper USB cable and the proper USB ports.
First, you need to enable USB debugging on your Android device (without connecting the Android device to your PC). Usually, this setting can found under 'Settings' and 'Developer options' but it can vary from device to device. On some Android devices, 'Developer options' may need to be revealed as they are hidden by default. If unsure, consult your 'User's Manual' or the manufacturer's web page for the information on how to enable USB debugging. The screen shot shown below is the already revealed 'Developer options' for the Nexus 5X and show that the USB debugging switch has been set to 'On'. The screen shot below it shows the message that pops up in the smart phone asking you to verify USB debugging by clicking on 'OK'.
If you find an item labeled 'Revoke USB debugging authorizations' on your Android device, select that and clear all previous authorization by selecting 'OK'. Note that if this item is not present on your Android device, you can safely assume that your PC is automatically authorized. The screen shot shown below is the 'Revoke USB debugging authorizations' for the Nexus 5X. Now click the Android device 'Back' button twice to exit the 'Developer options' and the 'Settings'.
Now check if you had previously run/installed the same 'Hello World' application on the Android smart phone. This can be done by pressing the 'App' button on the 'Home' screen of the smart phone (the middle lower button that looks a round button with two rows of 3 dots on it), and then searching for the app – delete it if found. Then close the 'App' screen – you should be back at the 'Home' screen.
Next, we have to make sure that the proper USB cable is used. The manufacturers of your Android device usually provide you with one – use that cable and none other. Unfortunately, the Nexus 5X smart phone comes only with type C USB connectors at both ends, so it would be impossible to make connections to a PC with type A USB connectors. Should this be the case with your Android smart phone and your PC, it would mean getting another USB cable for the connection between your Android smart phone and your PC.
You also have to make sure that the USB port to be used on your PC is working. Test this port out first by plugging in a thumb drive (or any other USB device) and if the PC recognizes this device, you can safely say that the USB port is working.
Now make sure that Android Studio is running the 'Hello World' project. Then connect your Android smart phone to your PC using the USB cable. Dismiss (or close) any file manager window on your PC if any pops up – also ignore any warning messages that may also pop up on your PC.
Then click on the 'Run' button in Android Studio's PC toolbar. As usual, the 'Select Deployment Target' window will pop up as shown below. The Nexus 5X API 25 AVD is selected as shown below. You may also need to authorize the USB connection to the smart phone for debugging with the PC's RSA key by selecting 'OK' on your smart phone (see below).
As soon as you press 'OK' on the smart phone, the top part of your PC's 'Select Deployment Target' window will change to 'LGE Nexus 5X (Android 7.1.2, API 25' – make sure that this item is selected (see below). Then click the 'OK' button on the PC to run the project on your Android phone device.
If everything is set up correctly, you should see the 'Hello world!' message displayed on your Android device's screen (see below). If not, see if there are any messages on your Android Studio status window of your PC. If the message mentions authorization (for example), then, most probably you have forgotten to set USB connection authorization on your device. Do it now and retry running the project again. The important thing to note here (if unsuccessful) is that Android Studio will display some message and this usually gives you a clue on what is wrong. If you still run into problems, then I suggest searching the Internet for your problem.
You can now close the 'Hello World' app on your Android device (usually using the 'Back' key). If you examine the apps on your smart phone, you will find an app labeled 'Hello World' (see below). This is, of course, the 'Hello World' app file (usually with a .apk extension) which Android Studio has downloaded for you. You can delete this file if you so wish. By the way, before you put your Android device aside after testing more new apps developed using Android Studio, remember to disconnect the smart phone first and then switch off USB debugging on the smart phone.
You should see the projects window on your PC. To close the 'Hello World' project on your PC, click on 'File' and the 'Close Project' menu items on Android Studio. You will be back to the welcome screen and the 'Hello World' project will be listed on the left-hand side pane (see below). To restart (or reload) the same project, make sure that the project is selected and then double-click that item – the project will then be started.
Updating Android Studio
If you start Android Studio and see an extra item on the last line, listed as 'Events' (indicated by the green arrow in the figure below), then it is time to apply updates. Below are some example screen shots of this process – these are examples only and may not reflect on what you see on the screen exactly. Note that the update notifications may appear on your welcome screen or your projects window.
Note that there are two types of updates – one is to the Android Studio itself (and indirectly, IntelliJ) and the other is to the SDK. One would require a restart to Android Studio and the other do not. If you see the window as shown above, first click on the 'Events' item followed by a click on the 'update' item as shown below. Sometimes when you click on 'Events', the message shown is maybe too long to display – click on the 'update' item again and the whole message will be displayed.
Then click on the 'Update Now' button and the update process will start. First, the patch file will be downloaded as shown, then the actual update will start (see below).
When the update is completed, the window will change as shown below. Then click on the 'Finish' button and the Android Studio window will reappear.
If there are more updates to be applied, this will be indicated by the green balloon to the left of 'Events' – else you should see a window as shown below – this means that all available update has been applied.
Updating Oracle Java
Follow the instructions below in order to update Oracle Java on your Windows 10 PC.
- Point your web browser to Oracle's download site and download the files for the latest version of Oracle Java, demos and samples, and finally the documentation. They should be named as 'jdk-XuXXX-windows-x64.exe', 'jdk-XuXXX-windows-x64-demos.zip' and 'jdk-XuXXX-docs-all.zip'. Note the 'X' in the filename can be any number.
- Double-click on the '.exe' file and follow the on-screen instructions to install the JDK. Note that the previous version of the Java is still present on your system – just do not delete at this time.
- If you have downloaded the demos (and samples) and docs, now would be a good time to install them.
- Next, we have to edit the JAVA_HOME system variable and change the version to reflect the correct one. Repeat the procedure to change the 'Path' system variable.
- To make the new environment variables effective, log out of the system, then log in again.
- If you are using the updated JDK in Android Studio's project structure, make sure that you reset the pointer to it.
- You can now delete the previous version of Java using 'Settings' or 'Control Panel'.
Summary Of Steps
- Download and install Oracle's Java JDK (or SE).
- Download and install Google's Android Studio.
- Configure SDK for Google's Android Studio.
- Create a new project on Google's Android Studio.
- Run the new project on the AVD to test it.
- Run the same project on an actual Android device.
That's it. You now have a 64-Bit Windows 10 PC which can be used to develop Android software. What was outlined in this 'how-to' is only the 'tip-of-the-iceberg' – there are more, lots more that you need to discover and learn!
If you are an experienced IntelliJ, Android Studio, Java, and Android programmer, enjoy! For those people who are new to Android Studio or Java programming, here are some links which I recommend you visit in order to learn about Android programming.
To learn how to use Android Studio for developing Android software, go here for a tutorial on this. To read the User Guide for Android Studio, go here for this. No matter how experienced you are, I urge you to read this manual.
To learn about the Intellij IDE (on which the Android Studio is based), go here for a tutorial on this.
If you are new to Java, then I would recommend searching the web for tutorials and the books 'Java For Dummies, 6th Edition' and 'Head First Java, 2nd Edition' as a guide.
If you are new to Java Programming for Android, then I would recommend searching the web for tutorials and the book 'Java Programming For Android For Dummies' as a guide. There is also another book by the same author but is more 'advanced' and is targeted towards Android developers. The title of this book is 'Java Programming For Android Developers For Dummies'.