Android SDK and tools – Getting started

Posted by

Introduction

This tutorial has helpful pointers for developers who are just getting started with Android. In addition to Google’s documentation on the SDK itself, there are lots of tools that come with the SDK and others that you can download elsewhere that make it a little bit easier to work with Android.

Get ready, this is going to be a tough journey

Let’s dispel the myth that mobile development is ‘EASY’, beginner-friendly, and suited for ‘web developers’. This is marketing crap and media hype. Mobile development is VERY difficult – it’s much more difficult and more complicated than web or server app development. If you have experience in web or server app development, this experience will NOT help you with mobile. Sample code from open source projects, tutorials, and books will not come close to getting your team ready for the minefield that is mobile development, deployment, and testing. The code your developers have copied and pasted might simply stop working on a real device (even though it compiles and runs in their simulator) due to a carrier limitation, device limitation, or user configuration choice.

Testing is such a huge cost center for mobile smartphone development, since simulators and API docs are marginally useful. They do not give you any idea what really happens to software running on a real device, on a real network. The experience of working on diverse hardware, software, and carriers all over the world, are critical in ensuring the success of your mobile project. If your mobile app works perfectly in the simulator, this means nothing at all, and you have just gotten started (not finished).

Mobile is a whole different ballgame full of hardware capability divergence, screen size & form factor divergence, carrier limitations, DPI independence issues, and it all gets increasingly more difficult when you get into cloud-connected multiplatform-mobile. We educate all our consulting clients on these topics when they get started, and the reaction is the same from most of them – one of disbelief. I have been in this space since 1997, which is way longer than just about anyone I have met. I have seen this space evolve, and it has come a long way, but it’s rules are different than those of web and desktop and server. And people who treat it the same always think smartphone mobile development is easy and inexpensive, and just like web development. These are typically the people who think that a mobile project will cost $5000 or less to implement!

Mobile is new, and very few people/companies are rolling out smartphone mobile app projects right now. Despite what you might see in Apple commercials or read in the blogosphere, not too many people are in mobile/smartphone space, and very few ISVs are actually making money from mobile/smartphone initiatives. All the money in the new mobile/smartphone space is going to hardware makers, and telcos, not ISVs. There are 100s of thousands of apps on the iPhone app store. Sure. But most of these apps are jokes, nothing more than glorified RSS readers, or dumbed down web views. This is just the state of this smartphone market right now. Hardware makers and telcos are so desperate to show off how viable their platforms are, they brag about how many useless apps they have in their catalogs, and don’t really talk about how few people actually use these apps. When they do get used, it tends to be for just a few seconds for the lifetime of that app on that smartphone by that user. They don’t talk about how much it costs to build these Android apps, or why people should be interested in building these BlackBerry apps, or not.

It is important to note that just because an app has been built, it does not mean that anyone will use it, or even know it exists. The current app stores (Android, BlackBerry, Apple) are really bad about discoverability of apps. They are all about promoting themselves, and they lose sight of the fact that the point of the store is to promote and sell apps (in the store), and not just promote the store itself. But this is not surprising, considering that the motivation behind the creation of these stores is for hardware manufacturers to give consumers one more reason to buy their products, because there are a plethora of apps in their respective stores. It has nothing to do with the quality of the apps or relevance to the user. It does not seem to matter that no sizeable number of users actually care about most of the apps, or are using them, much less paying for them. It was all started by Apple (a consumer electronics/hardware company), as a marketing tactic to sell more iPhones, and then BlackBerry jumped on the bandwagon, etc. This is the definition of hype and marketing bullshit, and this should not come as a surprise at all.

Not to mention that setting the price of an app to 99 cents does wonders to kill the ecosystem of ISVs that may have had a chance to make money from these stores. Smartphone mobile is not commodity, it is novelty. Novelty costs money. Novelty also has low marketshare, by it’s definition of being novelty, so you can’t count on volume to make money. To give you some perspective, feature phone marketshare is measured in Billions of units, smartphones are in 10’s of millions. By making such a ridiculously low price point the norm for smartphone apps, it eliminates serious companies from getting in the fray. It is not worth the investment of 100’s of thousands of dollars if the payoff is measured in the 100’s of dollars.

If you still want to proceed, don’t worry, we have training courses to empower you, and consulting services to enable you.

Getting the SDK and installing it

Download the Android SDK from here. Follow these instructions to get it setup.

The basic steps are as follows:

  1. Install the SDK Setup program
  2. Use the SDK Setup to download all the Android platforms that you might need (and all the docs and samples that you might need). Go ahead and download all of them. This way, you will have every single variation of the Android SDK from the first version to now. You can configure your IDE to work with whatever version you need at the time.
  3. Use the SDK Setup to create some AVDs or use the command line described below.
  4. Configure whatever IDE you want to use.

IDE plugins for the SDK

If you want to use the Android SDK with an IDE then there are quite a few to choose from. Here they are:

  1. Android SDK plugin for Eclipse – http://code.google.com/android/intro/installing.html#installingplugin
  2. Android SDK pluing for IntelliJ IDEA – http://code.google.com/p/idea-android/
  3. Android SDK plugin for Netbeans – http://wiki.netbeans.org/IntroAndroidDevNetBeans

Even if you don’t use an IDE, you can still use the Android SDK tools to get your program up and running, but there’s no good reason not to use an IDE 🙂 .

Configure your IDE with Javadocs from the SDK (optional)

Javadocs for the Android SDK are provided by Google. They are in the docs/sdk folder of your SDK install. Eg: if you installed the Windows SDK to c:androidandorid-sdk_m5_rc15_windows (the $SDK_HOME$), this is where they would be: “c:’androidandorid-sdk_m5_rc15_windowsdocssdk”. You should configure your IDE to find these Javadocs and this will save you a lot of time doing google searches on Android’s website.

Configure your IDE with android.jar from the SDK (optional)

There’s an android.jar file in the $SDK_HOME$platforms<your_platform> folder (which is where you installed the Android SDK) that you have to add to your IDE project, so that the IDE will know about the Android classes. The plugins will provide integration with the debugging, deployment, and monitoring tools of the SDK.

Need more help? developerlife.com offers training courses to empower you, and consulting services to enable you.

SDK tools

If you look in the $SDK_HOME$/tools folder (where $SDK_HOME$ is where you installed the Android SDK) you will find the following tools:

  1. emulator – the emulator executable, that runs the APK files
  2. adb – android debugger bridge, which is used to communicate with instances of the emulator
  3. ddms – this is the debugger for the emulator executable

emulator – run your APK files

Run this program to launch the emulator that you can run your APK files in. When you use plugins in your IDE to launch APK files, the emulator is started and the APK files are loaded it by the IDE.

You have to create an AVD in order to use the emulator in your projects. Here are some commands you can issue from the command line to manually build this (or you can use the SDK setup program):

@echo off
rem http://developer.android.com/guide/practices/screens_support.html#dips-pels

rem 320x480 med density, normal screen
call android create avd --force -n testdevice1.5       --skin HVGA    -t 2 -p androidavdstestdevice1.5

rem 480x800 high density, normal screen
call android create avd --force -n testdevice1.6_hidpi --skin WVGA800 -t 4 -p androidavdstestdevice1.6_hidpi

rem 480x854 high density, normal screen
call android create avd --force -n testdevice2.2_hidpi --skin WVGA854 -t 6 -p androidavdstestdevice2.2_hidpi

adb – install and uninstall APK files

The adb program is used to install APK files into the emulator that’s running. Here’s an example:

  • cd $SDK_ROOT$/tools
  • adb install $name.of.your.apk.file$. For example: “adb install SomeAndroidApp.apk”

To uninstall an APK file you have use adb to remove the file from the emulator itself. Here’s an example:

  • cd $SDK_ROOT$/tools
  • adb shell rm data/app/$name.of.your.apk.file$, For example: “adb shell rm data/app/SomeAndroidApp.apk”

To install or uninstall an APK file, please make sure that the emulator is already running.

ddms – debug and monitor your Android apps, and the emulator

This is the Android SDK emulator debugger. This is what you can do with your debugger:

  1. You can use this to look at LogCat output from your Android programs (Log.i(), Log.e(), etc) calls that are made in your Android program.
  2. You can set the telephony status of your emulator. You can control the network data i/o speed and latency. You can even fake an incoming phone call into the emulator. You can even create an incoming SMS message.
  3. You can take screenshots of the display of the emulator at any given time.
  4. You can view the contents of the emulator’s filesystem. This is useful if you want to see where files are stored (that you download in your apps for example).

Here’s more information from Google Android docs on ddms. The Eclipse plugin gives you full access to ddms functionality inside the IDE itself.

Emulator performance

To get an idea of what CPU speed your emulator is emulating try this:

  1. start a shell session (adb shell),
  2. then run “cat /proc/cpuinfo” to get the BogoMIPS.

Here’s more information on this.

Getting started with development

There is lots of documentation that you can get lost in. Here’s a good learning path to get started:

  1. Read this getting started slide from the SDK.
  2. Look at the tutorials on developerlife to get going 🙂
  3. Go through these 4 videos:

Part 1/3 – Android Architecture

Part 2/3 – Android app lifecycle

Part 3/3 – Building an Android app