Reader small image

You're reading from  Mastering Android Wear Application Development

Product typeBook
Published inDec 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785881725
Edition1st Edition
Languages
Right arrow
Authors (2):
Siddique Hameed
Siddique Hameed
author image
Siddique Hameed

Siddique Hameed is a pragmatic technologist currently working on Simplify Commerce (https://simplify.com), a payment gateway platform from MasterCard. During his diverse career roles, hes been crafting software for Fortune 500 companies to startups of industry domains ranging from finance, commerce, social media, telecom, bioinformatics, publishing, and insurance. He is passionate about technology, software and their effects on day-to-day lives. He is a strong believer in open-source software culture and actively contributes to many opensource projects. On times, he speaks at technology events, meetups, and mentor contestants in hackathons. He likes teaching kids and adults in programming, technology and software development, and volunteers on coding initiatives such as Girls Who Code, Code.org, and STEM (science, technology, engineering, and mathematics) programs. In his spare time, he likes traveling, goes on long road trips, and tinker with Raspberry Pi and build DIY gadgets.
Read more about Siddique Hameed

Javeed Chida
Javeed Chida
author image
Javeed Chida

Javeed Chida currently works as a senior software engineer for Apollo Education Group, a leader in global education. He has worked with several teams over the years developing multi-layered enterprise applications for companies spanning several industries including education, finance, medical, insurance, construction, and legal. He is passionate about Java portals and particularly enthused by the Liferay portal platform. He also has a love for clever and innovative technical documentation. Apart from periodically churning out articles as a highlighted community blogger on Liferay.com. He spends his leisure absorbed in creative writing projects, particularly classical poetry and fiction.
Read more about Javeed Chida

View More author details
Right arrow

Chapter 2.  Setting up the Development Environment

 

"Give me six hours to chop down a tree and I will spend the first four sharpening the axe."

 
 --Abraham Lincoln

In this chapter, we will discuss the steps, topics, and process involved in setting up a development environment using the Android Studio. If you have done Android application development using Android Studio, some of the items discussed here might already be familiar to you. However, there are some Android Wear platform-specific items that may be of interest to you.

Android Studio


Android Studio Integrated Development Environment (IDE) is based on the IntelliJ IDEA platform. If you have done Java development using IntelliJ IDEA platform, you'll feel at home working with Android Studio IDE.

Android Studio platform comes bundled with all the necessary tools and libraries needed for Android application development. If this is the first time you are setting up Android Studio on your development system, make sure that you have satisfied all the requirements before installation. Refer to the Android developer site (http://developer.android.com/sdk/index.html#Requirements) to check the items needed for the operating system of your choice.

Note that you need at least JDK version 7 installed on your machine for Android Studio to work. You can verify your JDK version by typing the following commands in the Terminal window:

If your system does not meet that requirement, upgrade it using the method that is specific to your operating system.

Installation


The Android Studio platform includes Android Studio IDE, SDK Tools, Google API Libraries, and system images needed for Android application development:

Visit the http://developer.android.com/sdk/index.html page to download Android Studio for your corresponding operating system and follow the installation instructions.

Git and GitHub


Git is a distributed version control system that is used widely for open source projects. We'll be using Git for sample code and sample projects as we go along the way.

Make sure that you have Git installed on your system by typing the following command in a Terminal window:

If you don't have it installed, download and install it by visiting, https://git-scm.com/downloads link for your corresponding operating system.

If you are working on Mac OS El Capitan or Yosemite, or Linux distributions such as Ubuntu, Kubuntu, or Mint, the chances are you already have Git installed.

GitHub (http://github.com) is a free and popular hosting service for Git-based open source projects. They make checking out and contributing to open source projects easier than ever. Sign up with GitHub for a free account if you don't have an account already.

We'll be using GitHub to check out various sample projects related to Android Wear and also for sample code for applications developed for this book. We...

Gradle


Android application development uses Gradle (http://gradle.org/) as the build system. It is used to build, test, run, and package the apps for running and testing Android applications.

Gradle is declarative and uses convention over configuration for build settings and configurations. It manages all the library dependencies for compiling and building code artifacts.

Fortunately, Android Studio abstracts most of the common Gradle tasks and operations needed for development. However, there may be some cases where having some extra knowledge about Gradle would be very helpful. We won't be digging into Gradle now, we'll be discussing it as and when needed during the course of our journey.

Android SDK packages


When you install Android Studio, it doesn't include all the Android SDK packages that are needed for development. The Android SDK separates tools, platforms, and other components and libraries into packages that can be downloaded, as needed using the Android SDK Manager. Before we start creating an application, we need to add some required packages into the Android SDK.

Launch SDK Manager from Android Studio, Tools | Android | SDK Manager:

Let's quickly go over a few items in the preceding screenshot.

As you can see, the Android SDK's location is /opt/android-sdk on my machine. It may very well be different on your machine depending on what you selected during the Android Studio installation. The important point to note is that the Android SDK is installed in a different location than Android Studio's path (/Applications/Android\ Studio.app/).

This is considered a good practice because the Android SDK installation can be unaffected depending on a new installation or upgrade...

Android Virtual Devices


Android Virtual Devices (AVD) will enable us to test the code using Android emulators. It lets us pick and choose various Android system target versions and form factors needed for testing.

Launch Android Virtual Device manager from Tools | Android | AVD Manager.

From the AVD Manager window, click on the Create New Virtual Device button in the bottom left and proceed to the next screen and select the Wear category:

Select Marshmallow API Level 23 on x86 and leave everything else as the default settings, as shown in the following screenshot:

Note

Note that the current latest Android version is Marshmallow of API level 23 at the time of writing. It may or may not be the latest version while you are reading this chapter. Feel free to select the latest version that is available during that time. Also, if you'd like to support or test in earlier Android versions, feel free to do so on that screen.

The configuration window will appear after clicking the Next button:

After...

Let's build a skeleton application


Since we have all the components and configurations needed for building a wearable app, let's build a skeleton app and test out what we have so far.

From Android Studio's Quick Start menu, click on the Import an Android code sample option:

Select Skeleton Wearable App from the Wearable category:

Click Next and select your preferred project location.

As you can see, the skeleton project is cloned from Google's sample code repository from GitHub:

Clicking on the Finish button will pull the source code, and Android Studio will compile and build the code and get it ready for execution.

The following screenshot indicates that the Gradle build has finished successfully without any errors. Click on the green play button as shown in the following screenshot to run the configuration:

When the app starts running, Android Studio will prompt us to select the deployment targets. We can select the emulator we created earlier and click OK:

After the code compiles and...

Summary


We discussed the process involved in setting up the Android Studio development environment by covering the installation instructions, requirements, SDK tools, packages, and other components needed for Android Wear development.

We also checked out the source code for a skeleton wearable app from Google's sample code repository and successfully ran and tested it on the Android device emulator.

In the next chapter, we'll be working on a real-world Android Wear application from scratch with all the configuration and setup we have created so far.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Android Wear Application Development
Published in: Dec 2016Publisher: PacktISBN-13: 9781785881725
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Siddique Hameed

Siddique Hameed is a pragmatic technologist currently working on Simplify Commerce (https://simplify.com), a payment gateway platform from MasterCard. During his diverse career roles, hes been crafting software for Fortune 500 companies to startups of industry domains ranging from finance, commerce, social media, telecom, bioinformatics, publishing, and insurance. He is passionate about technology, software and their effects on day-to-day lives. He is a strong believer in open-source software culture and actively contributes to many opensource projects. On times, he speaks at technology events, meetups, and mentor contestants in hackathons. He likes teaching kids and adults in programming, technology and software development, and volunteers on coding initiatives such as Girls Who Code, Code.org, and STEM (science, technology, engineering, and mathematics) programs. In his spare time, he likes traveling, goes on long road trips, and tinker with Raspberry Pi and build DIY gadgets.
Read more about Siddique Hameed

author image
Javeed Chida

Javeed Chida currently works as a senior software engineer for Apollo Education Group, a leader in global education. He has worked with several teams over the years developing multi-layered enterprise applications for companies spanning several industries including education, finance, medical, insurance, construction, and legal. He is passionate about Java portals and particularly enthused by the Liferay portal platform. He also has a love for clever and innovative technical documentation. Apart from periodically churning out articles as a highlighted community blogger on Liferay.com. He spends his leisure absorbed in creative writing projects, particularly classical poetry and fiction.
Read more about Javeed Chida