Step 1, Getting the source code
This task assumes that you have set up your device or telephone to work as a development device first. It also assumes that the Java SDK, Eclipse, Android starter SDK, Android platform SDK for your device, and ADT plug ins have been set up in Windows 7.
Instead of a ‘Hello World!’ program, we are going to use an existing application that is already developed and available in the Android Market (Google Play)
We will use an application called the Simple Loan Calculator, its source code is at Google Code and developed by Andrei Samkov. It is an open source utility and it is actively maintained. What this means is that some of the code you will find once you download the package may be different from what is explained here. In any case, we will make the source code we use for this tutorial available in a .Zip file at the end of this task.
Goals of compiling the first application
- Obtain the full source code of the application available from a Subversion repository in the Google Code website (Subversion client not necessary)
- Application will be deployed to an Android device and not to a virtual device.
- Learning about how resources are defined in Eclipse
- We are only expected to make a very simple change to the existing application: remove the ‘Donate to PayPal’ button from two menus.
The Simple Loan Application is available from Google Play (formerly the Android Market). It is Open Source and it is possible to work with the entire source code.
The object of the application is to allow a user to enter a loan principle, its number of payments and expected discount or downpayment and calculate either:
- A schedule of payments
- A graph showing the ratio of capital to interest for the loan
- Different options to output the results: csv file for importing into Excel, e-mail
If we compile the application as it is, there would not be a way to confirm that it is different from the one in Google Play, so we will remove the ‘Donate’ buttons available from the main menu and from the scheduled payments menu.
(Update: 18 June 2013) The Simple Loan application developer has decided to remove most menu buttons and this includes the ‘Donate’ option used in this tutorial. If you wish to continue this part of the tutorial, you need to work with the original version of source code which is available from the location below:
You may still get the source code directly as described, but most menu buttons are missing.
Obtain the source code from its origin
When you browse to Google Play and search for ‘Simple Loan Application’, you are presented with the following search result:
Clicking on the application’s profile, we find out that the application is open source and there is a link to the Google Code project:
When you click on the source link, we are provided with the Subversion checkout command:
svn checkout http://android-simple-loan-calculator.googlecode.com/svn/trunk/ android-simple-loan-calculator-read-only
Brief explanation of the command
svn checkout: this is a command that can be run from the command line or from checking out into a folder using a Subversion client.
http://android-simple-loan-calculator.googlecode.com/svn/trunk: this is a full name for the repository location within Google code. There are many such Android projects that can be obtained this way, there is no need for registration.
android-simple-loan-calculator-readonly: this is a user-defined name, it will become a folder within your hard disk. You can use helloworld, simpleloancalculator, or any name you wish.
If you do not have a Subversion client installed in Windows 7 or you don’t want to install Subversion at all, you may use the following .NET application to download the repository: Download SVN (and GIT)
I will be using this application and using the following folder to download all code:
Destination folder: C:\development\android\slc
Procedure for downloading source code:
- After downloading and extracting the ‘Download SVN’ application, run it and set the following values:
SVN Source URL:
- And then click ‘Start’
At the end, you should have the project files checked out to your hard disk like this:
The source code used in this tutorial is also available from this location:
Next, in Part 2, we import the existing project into a new Eclipse workspace and make the necessary changes to allow this application to compile for the first time.
Subscribe to this blog’s RSS Feed for updates