Getting Started with Android Programming

June 19th, 2013 Leave a comment
Like the article?
Getting Started with Android

Android is the most-common operating system on mobile devices around the world. Phones, tablets, etc. that utilize it are outselling Apple iOS-based devices by nearly two to one globally. The Android App markets, like Google Play, are filled with useful apps for users to download and are eagerly flooded with users looking to enhance their devices.

Yet many developers are unsure of how to get into Android programming. Compared to the iOS SDK, getting a clear path set for Android development isn’t as well-mapped. That is changing quickly. Here is a simple roadmap you can follow to get started programming Android apps today.

If you already know Java, then you’re well on your way towards becoming an Android developer. Those familiar with Java will also have a far easier time adapting to the way development takes place. Any object-oriented language background, however, will help in this regard. Familiarization with markup languages like HTML, Adobe Flex or XML tags is also a must as layouts in Android are tag-based.

To get started, you’ll need a copy of the Android SDK (software development kit), which includes an emulator. This is how you’ll check and test your work and the emulator lets you do this without having to load your software onto a device every time you want to check something. Most developers experienced in Java probably already have a favored tool, such as Eclipse, and most of those tools now integrate with the Android SDK so you can use them together. If you don’t have a favorite, one can be found all over the Web or you can simply use the Android Developer Tools themselves.

Experienced iPhone developers will find that while Java is less verbose than Objective-C, it’s also not as elegant and many core functions of an Android device are not as clear-cut and easy to access as they are in iOS. This is mainly because iOS devices are fixed and pre-defined by Apple whereas Android devices are many and varied thanks to an open market. The greatest advantage to Android, however, is that it is open source so if you have a question about how something works or why it works the way it does, the source code for the OS is readily available to peruse.

One thing many Android developers find frustrating at first is that diversity of hardware. Like programmers for the PC, Android developers often have problems when one device’s hardware is different than another’s (or isn’t there at all). Cameras, for instance, are sometimes present on a device and sometimes not and some devices have more than one. App code must be able to handle this possibility. Layouts are also important because while the app doesn’t change, the device it’s running on definitely will and the difference between a 5-inch phone and a 10-inch tablet are huge. Most of the time, this can be handled with scaling, but some things might change if your app has specific screen requirements.

Luckily, there are a lot of support services for Android developers because the community is a thriving, open source group. Sites like the Android Developers site ( with all of its documentation, groups, etc. is a great hub to begin finding answers. Of course, just searching for the problem or going through the Android OS code is also helpful. The code and its various APIs are all freely available and can show a budding developer a lot about what’s going on in that little handheld.

Start a Project, Run the Emulator, Start Programming

Once you have the foundation in place, dive right in! Assuming you have only the SDK tools and a command line, rather than a programming environment like Eclipse, we’ll cover the basic steps required to get your project started. A project consists of all of the files used to compile and create your app, including your source code once you’ve written it.

Start by navigating to your Android SDK tools/ path and execute “android list targets”, which will print a list of the available Android platforms that you’ve downloaded for our SDK. Select the highest version possible for your target to optimize for the latest devices or select a lower target if you’re working on legacy tools (lower-end, older devices). If you don’t have any targets listed, use the Android SDK Manager to add platforms and packages.

Once you’ve noted the target ID from your list, execute “android create project -target –name MyAppName -path /MyAppName -activity MainActivity -package com.example.MyAppName”

What you’re doing here is telling the SDK that you’re creating a project and under what target platform. You’re giving the project a name (MyAppName), telling it where to save it (workspace area), adding a description of a MainActivity for the app, and finally, giving the project a package delineation you can call when needed. Anything in <> above should be replaced with actual information you supply and you can change the MyAppName and MainActivity to whatever you wish (do not use spaces or special characters).

For now, all your app will do is execute and print a simple message to the screen (default setup). Let’s see how that works by using the emulator to test it. Launch the Android Virtual Device Manager from the command line by navigating to your SDK directory and the tools/ path, then executing “android avd” there. This launches the Virtual Device Manager.

Click “New” and fill in the details for the device you’d like to use (device, platform target, virtual SD card size, and skin). Your emulator may have pre-set devices already in it, depending on the SDK package you’ve downloaded. Your target should be equal to or better than the target you used in your package setup. A sample would be the Galaxy Nexus with Android 4.2 under the 4.2 platform with an API level of 17 and a CPU/ABI of ARM (v7a). Once you have your device created, select it and press “Start.”

Once the emulator boots, unlock it and then enter the command line and navigate to your Android project’s root directory. From there, enter “ant debug” and then “abd install bin/MyAppName-debut.apk” then locate the activity on your emulator (probably called MyAppNameActivity) and open it.

You’ve now successfully set up a project on the SDK and checked it through the emulator. Congratulations! You’re now ready to begin developing. Have fun!

Help us spread the word!
  • Twitter
  • Facebook
  • LinkedIn
  • Pinterest
  • Delicious
  • DZone
  • Reddit
  • Sphinn
  • StumbleUpon
  • Google Plus
  • RSS
  • Email
  • Print
Don't miss another post! Receive updates via email!