Android: Developing w/ the SDK ADT bundle

This semester, I’m taking a course on Android development. So I’ll be posting a bit more Android-related stuff as we go along. I’m developing on the MacBook Air, so get comfy w/ the command line.

To get started, grab a copy of the Android SDK. The Android Development Toolkit (ADT) bundle is pretty awesome. It comes w/ Eclipse and the plugin all setup already:

http://developer.android.com/sdk/index.html#mac-bundle

I unzipped the .zip file in Downloads; i.e. /Users/kzhiwei/Downloads, so the full path would be something like:

/Users/kzhiwei/Downloads/adt-bundle-mac-x86_64

Now you need to connect up your Android device (I use the Nexus S). The truth is, the ADT plugin comes w/ the Android Virtual Device (AVD) Manager. So you could, theoretically emulate any Android device, but the emulated device takes too long a time to boot up, it’s insane not to use a real hardware device. You’ll need to setup Android debugging: Settings > Developer options > On > Android debugging. There are two other useful options here: Stay awake and USB debugging notify. I keep them on, but it’s not mandatory.

Now, we’ll need to find out what is our device serial number. Fire up Terminal, and navigate to /Users/kzhiwei/Downloads/adt-bundle-mac-x86_64/adt/sdk/platform-tools:

woteba:platform-tools kzhiwei$ pwd
/Users/kzhiwei/Downloads/adt-bundle-mac-x86_64/sdk/platform-tools
woteba:platform-tools kzhiwei$ ./adb devices
List of devices attached
3xxxxxxxxxxxxxxx device

I’ve masked out my device ID, of course. Just remember the starting digit, and then you are basically ready to start working w/ Eclipse. I do this by using the Finder, and then navigating to adt-bundle-mac-x86_64/eclipse. There’ll be an Eclipse.app somewhere, so double-click, and then wait a bit. Now we’re ready.

File > New > Android Application Project. Under Application Name and Project Name, input “Foo”. Under package name, input “com.wordpress.kzhiwei.foo”. So it’s basically my domain name in reverse, plus the app name (foo). Next we’ll need to define SDK levels. The defaults are good enough:

Minimum: Froyo
Target: Jelly Bean
Compile with: Jelly Bean
Theme: Holo Light w/ Dark Action Bar

Stay with me! Click Next (just use the defaults for the next few pages). You should see your newly created project (Foo) in the Project Explorer. Right-click the project, and then Run As > Android Application. The first time you do that, there’ll be an option to choose either an AVD, or an Android hardware device. We’ll check our device, of course, and then check “Use same device for future launches”, and then go. There’ll be some activity on the device, and then your new application should run. It just says “Hello world!”. Awesome, we are done here.

Hopefully I’m really hardworking and I’ll continue posting up stuff w/ real code in a bit.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s