Writing a Real Android App from Scratch - The World Beyond the Hello, World!

January 11, 2013

Developing real software is difficult, time-consuming, and ugly. It seems easy when you read the manuals and design guidelines but when you sit down and actually start writing it, it won’t take you long to realize that writing anything beyond a “Hello, World” program is really difficult. The problem is not with you, or with the manuals. The problem is that everything comes in pieces, and it takes a different magnitude of efforts to join the pieces together. Manuals talk about different components, and leave assembling these components to you. The main problem is that those components neither fit together well nor are enough. You learn about Fragments and Action Bar but in a real app you won’t be able to use them with ease because they are not backward compatible. So you’ll end up using ActionBarSherlock instead. To spice up your app, you also certainly want to use some other libraries such as StickyListHeaders, ViewPagerIndicator, Universal Image Loader, and AndroidAnnotations etc. Started sensing the complexities here?

Even few years back, when the platform was relatively new with fewer components, developing apps for Android was difficult. With the introduction of new components, new and deprecated APIs such as Action Bar, Contextual Action Bar, Fragments, and ViewPager etc, it has got more complicated. The most frustrating part with app development on any platform is that there are rarely any resources that actually tell you how to compose all these nice components in a real app. And even if there are, these resources are scattered and talk only few parts of the whole app. You can find documents, and download/ clone/ fork open-source apps for studying the code. There is the source – the components and the documents, and there is the destination – the app itself. What is missing is the real path that joins the source with the destination. In this tutorial series I’ll attempt to draw that path.

In next several parts of this tutorial series, you will get the real experience of developing an Android app by actually writing it from scratch to finish. It is not a bunny ‘Hello, World’ app but a real working app which uses, among others, Fragments, Google Maps, Tabs, Geocoder, LocationManager, Camera, Gallery, SQLiteDatabase, as well as third-party libraries such as Universal Image Loader, ActionBarSherlock, and StickyListHeaders etc. We will also implement our own custom Action Bar as well as make use of the Contextual Action Bar.

Please remember that this is going to be a long series, and I will publish it in multiple parts. I might end up compiling all the parts as an e-book but I don’t have a plan to do that right now. The well-commented source is already hosted on GitHub. You can fork/clone it and follow along step by step.

During the development, we will break the app features into different milestones, adding one feature at a time. Each milestone will be tagged with a version number: v0.x.x . So even if you missed, or messed up something, you can always start from a new milestone.

To keep things more interesting, and for the sake of brevity, I won’t be explaining concepts that have already been explained in details in other places esp. in the official Android documentation. The intention of writing this tutorial is not to get bogged down with details about a component but to see how it fits together with other components. I won’t be explaining what Activities are, or what an AndroidManifest.xml file is. Believe me, there are plenty of resources out there that define and explain the basics clearly. If you got lost during this series, follow those resources, and come back. Don’t try to skip something that you are having hard time to understand otherwise you’ll never learn it. All these mean that this tutorial is NOT for absolute beginners. This goes without saying but I do expect you to be already familiar with Java language as well as Android development basics. I will try my best to describe new topics where appropriate and will add the links to external resources for further and advanced details.

At the end of some parts, there will also be simple assignments that you can complete. You can completely skip these assignments as no proceeding parts will depend on any code from these assignments. The assignments will be simple, and few and far between. As a reward, few of the lucky and hard working readers, who complete all the assignments, will get a free coupon code each for the Commonsware Warescription. You can use these coupon codes to download the Commonsware Android books for free with all the updates for six months. The books are really good and very helpful to take your Android development skills to the next level. To be able to eligible for the coupon code, you need to make your nicely commented assignment source code publicly available. I strongly encourage you to attempt these little assignments.

I don’t promise you to help you out with every problem that you are going to face during this tutorial series but I will try my best to help you out esp. when you are stuck with an error. If you got stuck with errors, let me know in the comments, or create an issue, and be very clear about your problem. Use something like http://pastie.org/ to paste the errors and your code snippets, and share the link. Don’t forget about other resources for asking help such as StackOverflow. The thing is – don’t give up! Let minor errors not stop you from completing this series.

Also, make sure you are already familiar with the IDE that you will be using. I will be using IntelliJ IDEA 12, and so does the project hosted on GitHub for this tutorial. However, be assured that there won’t be any IDE specific code to deal with.

In the first part of this series, we will talk about the app itself, get to see and play with it, and then we will finish up by setting up the project itself. I hope you are as excited as me to write a complete Android app. If you know anyone looking for a tutorial like this, let them know. You can help spread the words by tweeting about it on Twitter, or sharing it on Google+, Facebook, or any other social network sites. The more the merrier!

You can follow me on Twitter, or add me on Google+.

BTW, have your heard about LightPaper?

See you in the next part.

Discussion, links, and tweets

By day, I ship code at MetaGeek, by night, I hack on my personal projects, and finally, when I get some off time in between, I also serve as a CTO for ClockworkEngine, LLC where so far we have launched two products - Spyglass and LightPaper. Call be a serial coder if you want.

comments powered by Disqus