Friday, November 04, 2011

A Primer To Android Development

As most of you know, Android is a mobile operating system initially developed by Android Inc. and presently being developed by the Open Handset Alliance led by Google. Android consists of a modified Linux kernel and software built on the Apache Harmony framework (an open source Java implementation). The best thing I like about the Android platform is its versioning. The code names are released in alphabetic order of dessert items - Cupcake, Donut, Éclair, Froyo, Gingerbread, Ice Cream Sandwich and Jelly Bean.

I am a newbie myself when it comes to Android, so the past few days I was trying to understand the various development models of Android. During my search I came across several good tutorials. This blog post is primarily to consolidate these tutorials for beginners like me.

Android, like most open source Operating Systems allows developers to look at development from two different perspectives - working on Android (Application development) and working with Android (Operating System development, not possible with proprietary Operating Systems). Google understands this and therefore has two different sites for Android developers - Android Developers (has the Android SDK to build applications) and Android Open Source Project (has the Android source code).

Android Developers

The Android Developers site provides various Development Kits to create applications for the Android platform. The Android SDK allows developers to write applications for the Android platform in a slightly modified version of Java which runs on a virtual machine called Dalvik.

The Android SDK can be installed by following the instructions specified here - Installing the SDK. And in case you want to start programming right away, here's a classic Hello World tutorial.

The Java APIs are pretty much what most developers use. However there might be situations where you would like to harness the true potential of the underlying Linux kernel through a low level language like C. Android does allow developers to do that but they cannot call the C binary directly as an application, they will need to go through Java with the JNI (Java Native Interface). This methodology of development is supported by the NDK (Native Development Kit).

The Android NDK can be installed by following the instructions specified here - Installing the NDK. The NDK does come with the Hello World example but it isn't as easy as the regular one.

The most useful tool Android provides developers with is the Android Debug Bridge. It is a command line utility that supports several commands like pulling/pushing files to and fro the device, installing applications, etc. This is one tool that every Android developer will have to use irrespective of whether he is developing applications or playing with the source code. Please note that the adb is part of "Platform Tools" which can be installed through the Android SDK Manager. If you stuck trying to install adb, read this.

Android Open Source Project

The Android Open Source Project site provides access to the source code of Android. A majority of the operating system infrastructure of Android is distributed under the Apache License and the core kernel is licensed under the GPLv2 License.

Certain developers use the Android Open Source Project to find vulnerabilities in the Android operating system and exploit them to execute tasks which cannot be done normally like attaining root access. Examples of these exploits are GingerBreak, psneuter, etc. Typically these vulnerabilities are patched for security reasons.

A majority of developers use the Android Open Source Project to modify and customize the operating system to create custom images. Several vendors add device drivers for their hardware and install pre-release applications to the operating system before flashing it onto the device. There have also been situations wherein vendors have customized the UI to suit their product lines before flashing.

You can obtain the complete source of the Android operating system by Downloading the Source Tree. There is an awesome tutorial on building Android 2.3.7 on Ubuntu 11.10 (64 bit) here. Even though the AOSP site specifies instructions on compiling the code, they are a bit outdated so visit the above link if you are stuck anywhere.

Underneath the layers of application frameworks, Android is primarily a Linux kernel and therefore is built on a C library. Unlike the traditional Linux based operating systems, Android uses a custom tiny libc called bionic. C programs can be written in an Linux environment running on x86/x64 architectures and cross compiled to Android running on ARM by linking Bionic to gcc. Here is an excellent tutorial which shows you exactly that. The compiled code can be run using adb shell. However note that codes compiled this way aren't recommended to be used with Java applications, the NDK should be used instead.


asoya said...

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that i enjoyed reading it. Nice blog. I will keep visiting this blog very often. USB Pen Drives

arkay1 said...

Hi.. i found the info that you provided on this tablet useful. I am thinking of buying one mainly for the android apps. But i read in your post in HCL website "the lack of Android market is a major drawback" Is it true...Will I not be able to download android apps on this tab

Gautam Muduganti said...

You can download apps on the tablet but you will have to do it either by downloading and installing an .apk or by using other app stores.

Android app development said...

This is one of the useful post.By read your post I got good knowledge about Android.Android is one of the popular mobile Operating system.We are also providing good logic related to Android.

Vee Eee Technologies said...

Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
Vee Eee Technologies

mithun said...

Thanks for sharing, I will bookmark and be back again

Android App Development

murugan said...

My cousin recommended this blog and she was totally right keep up the fantastic work!

Android App Development

Shariq Waseem said... @ Movers and packers in Delhi @ Delhi packers and movers