Sunday, January 6, 2013

How we build a cloud Android applications

I would like to present a tutorial for building mobile cloud applications, which we have developed with my colleagues during the three month Internet Application Development course at CTU. I will overview the selected technologies and why we selected them. If you like to build our sample application, refer to the details in the final presentation.

Customers as well as industry are demanding stable and robust mobile/cloud applications with user friendly UI. Mobile applications are taking advantage of the sensors in terminals, computational power and all information in the cloud. Number of smart phones is rapidly growing as well as the number of mobile apps. These trends were for us the key motivation for the course and for the selection of a sample application. It is a Android app storing the client data in the cloud.

There are many different technologies to choose from. What are the key components of the sample app?  Here are our choices. The Amazon EC2 API is the de facto standard in the cloud API. The educational accounts on Amazon are free, but students are required to pull out the credit cards ... Thanks to we can use for free several servers  in their infrastructure and it made our decision simple. We have decided to use the Eucalyptus cloud operating system. Its API is very similar to EC2. Application server is Tomcat 7 providing the java sandbox. An obvious choice is the MySQL as a database. We run all on Ubuntu 12.04. The client side is a native Android client also in in Java. The Android SQLite is used as the local storage. Client and server follow the REST architecture.

Our students are running different operating systems on their notebooks – Windows, Linux, OS XW, therefor we had to make some decisions to unify the development. We have decided to leave the code development IDE on the native OS. We recommended  the Eclipse, which coves all our students variety of OSs. The run time unification is not that simple. The reason is that we wanted to provide a step-by-step command description and they are OS dependent. The virtualization is the answer. We will use the Virtual box and an image of Ubuntu 12.04.

We sticked to the most widely used model the REST architecture for the sample application. The source comes with a Maven pom file to build and deploy the final war file. The code can be downloaded from Github. It provides the simplest CRUD functionality accessed through the REST API. Students cloned this code to their workstations as a starting point for testing and debugging their own modifications

To further simplify the development we have chosen to use Vagrant nicely managing the images in the Virtual box. Vagrant installs the Chef solo in the VM, which takes care about the provisioning. Chef proved to be a very simple and useful saving us lot of troubles. It uses cookbooks and receipts.  The whole provisioning process is reasonably fast and simple. Vagrant ssh, and IP forwarding allows to further tweak the installed components from the command line and executing some configuration and initialization scripts for MySQL before starting the app war.

To test the server part we use a simple Chrome plug-in HTTP client. It enables us to test the whole REST API, modifying headers and having the returned data nicely displayed. Excellent not only for demonstrations and teaching!

The final step was to move the application war file to cloud, to Eucalyptus. For this purpose we have installed the Eucalyptus command line utility euca2ools. After exchanging the public keys all commands for instantiating VMs in the cloud are at hand. Eucalyptus provides the IP address of the VM instance. We have again used the Chef solo to install the same pair of Tomcat and MySQL and we used the same process for provisioning and testing as in the local VM.

We have decided to design the client on the Android platform. All tools are available for Eclipse. The applications apk files are easy to distribute. Second, thanks to Samsung we were able to give to our teams bunch of Android tablets for development and testing. The Android application development compared to the server part is much more self-contained. The only non standard action is to install Samsung drivers on Windows to run the debugging and testing on the target tablet. The Java code and development are well described with programming examples at Google pages.  For our purpose we have provided a more complex sample of code. For most of the web applications storing data in the cloud is  essential to use data cash on the client to handle connectivity problems, therefore we have shown the use of the basic SQLite. This time  the DB configuration etc. is part of the code. You also will see some threads handling the background operations in the example. If all works fine, you should be able to run the whole app from your Android device.

At the end of the course students delivered 10 demos, pilot working applications. Most of the teams used the suggested technologies. Some of the apps work on both tablets and phones two.

If you are interested in details or follow the sample development look at the presentation. It provides links to the sample code and shows step by step the building commands. You can cut and past them and follow what we have done. You should be OK except for the Eucalyptus part, which requires creating an account. You can instead use the AWS with almost exactly the same set of commands. This sample application is only a bases for building real applications. We show the installation and usage of development technologies, which are state of the art and useful for serious design. Many required details are missing, but you can start your project with something running. We will continue improving the presentation and add more functionality, other front ends etc. The course took three months and we have been step by step introducing the technologies to our students, therefore take your time and enjoy the details to gain full understanding.

Good luck and let me know about problems you have encountered. I will also welcome suggestions.
Enhanced by Zemanta


  1. Nice alternative for Chrome HTTP client might be REST Console (

  2. This comment has been removed by the author.