Our book, "Introduction to Android Application Development: Android Essentials, Fifth Edition," written by Joseph Annuzzi, Jr., Lauren Darcey, and Shane Conder, contains many sample applications referenced throughout. We would like to share our code samples with you to help you learn the material of the book which can be accessed below.
These code samples were created with Android Studio for the 5th edition.
Being that Android Studio is now the official IDE for Android development, and Eclipse is no longer going to be supported, we thought it would be important to provide updates on the code samples for Introduction to Android Application Development: Android Essentials, Fourth Edition, so that you may use the code samples with Android Studio.
Since the code samples were created to work with Android SDK Version 4.3, API Level 18 (Jelly Bean), and Android SDK Version 4.4, API Level 19 (KitKat), the samples have been made to work with these API levels, and where previously available, will also work with lower API levels if the older code samples were also made to support any lower API levels.
In order to get Java and Android Studio configured for your system appropriately, we will list the best resources for walking you through how to do so in the next few paragraphs. Make sure you go through each link presented here to make sure you are configuring your system appropriately. Don’t skip reading the information posted at the links presented here, these are very important steps to getting your system configured.
First off, we would like to point out some helpful resources so that you are able to install Java on your system. Android Studio currently requires using JDK version 7. Here is where you will find the downloads for your system, Oracle Java SE Development Kit 7 Downloads found here: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Once you have installed Java for your system, you need to install Android Studio. You may need to perform an additional set of steps depending on your system too. The official Android developer documentation should describe those steps, and any trouble shooting you may need to perform at the Android Developer Tools, Official Documentation titled “Installing Android Studio” found here: https://developer.android.com/sdk/installing/index.html?pkg=studio. Here you may be presented with any additional steps necessary so that Android Studio is able to detect the correct Java installation on your system, and is able to run properly.
The only recommendation we have for installing Android Studio, is to make sure you select all components to install during the installation. You will be presented with a dialog for selecting the components to install that looks similar to this screenshot:
Note that this will only install the latest Android SDK and Android Virtual Device available. There is a component named “Performance (Intel® HAXM)”. If this is not available on your system to install, don’t worry about this. If it is available, you will want to install this as it will boost the performance of the emulator for running the Android Virtual Devices.
If you are installing the latest version of Android Studio that means API Levels 18 and 19 will not be installed by default, as only the latest will be installed. In order for the samples to work, you need to also install APIs level 18 and 19 on your system. Here is a detailed guide on how to install the appropriate SDK packages and support libraries on your system, Android Developer Tools, “Adding SDK Packages” found here: https://developer.android.com/sdk/installing/adding-packages.html
Assuming that you have followed all the detailed installation and configuration instructions presented in the links found in this blog post appropriately, you should now be ready to download and open the sample source code provided with this book for running in Android Studio.
Make sure you have already downloaded the samples which can be accessed from here:
Then, start Android Studio, and choose the option “Open an existing Android Studio Project” and browse to the root folder of the sample project of your choosing and click “OK”. Your installation of Android Studio will then begin loading and building the project. Assuming you performed all the installations steps appropriately, you should not encounter any issues. If you did encounter any issues, Android Studio will most likely present how to fix these issues in the “Messages” window, showing any errors encountered, with tips on how to fix them. The errors usually include clickable tips that are meant to help you work through fixing these issues. If you receive any issues, perform the recommended fixes until there are no issues left with your installation.
Once you have an emulator running or a hardware device configured, in Android Studio, select “Run” from the menu, and choose “Run ‘app’”. You should then choose the appropriate emulator/device that is capable of supporting API Level 18 and 19 for installing the app on, then click “OK”. You will see the app install on the emulator/device. We hope this blog post is useful for helping you get the code samples working for Android Studio.
You may also like to know about two other valuable resources for those coming from Eclipse ADT:
Ever since the preview release of Android M was released, there was speculation that Android M would be named Marshmallow. Well in the past couple of days, Google officially revealed that Android M will in fact be code named Marshmallow. The preview release had a code name of MNC. You would see the MNC code name within Android Studio, and many have said that MNC stood for Macadamia Nut Cookie according to this blog post, and rumored to have been the internal code name used by Google employees. If you want to learn more about the official release of Android 6.0 Marshmallow, you should read the official Android blog here, and if you have not already done so, you should start preparing your apps so that they are ready to run on Marshmallow as it will be available on Nexus devices shortly.