Dec 18 2012

Compiling and running your first Android application in Windows 7: Part 3: Modify application and deploy

Category: android app tutorial,development devicewpgeorge @ 2:29 pm

In Part 2, we advanced as far as compiling the Simple Loan Application without errors. Up to that point, we had not yet deployed the application to our device.

(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, otherwise you may skip to this step.

Location of original Simple Loan Calculator:

For this final task we have three simple goals:

1. Disable the Paypal donation button present in two menu layouts.

2. Change the application’s version number to make it distinct from the original application.
3. Recompile and deploy to our Android device

Each screen or layout in an Android application  is designed in code as a separate XML file per screen.

In case of the Simple Loan Application, the following layouts exist:

main: contains the base of the application and all the different variable fields used to calculate loans.
schedule: contains the detail of payments once they have  been calculated
compare: similar to the payment schedule, but it allows comparison amongs different payment options
help: user help screen

You can look for layouts under folder <project location>/res/layout
Although menus are displayed in specific screens, they are stored in separate layout files themselves.

Menus are xml files under folder <project location>/menu


  • Open your eclipse project defined in the previous step and at the Package Explorer window navigate to:

Subfolder /res/menu

  • Double click on mainmenu.xml. This activates an Android Menu layout definition.


Each menu option is represented by an item (‘I’ icon).

  • Click once on the donateMenu item and at the right side, scroll down to the ‘Visible’ attribute. Set the attribute to ‘False’


  • Repeat the task with the other menu layout called ScheduleMenu.xml

That’s all there is to disabling the PayPal donation menu item.  If you click on the ‘Source’ view at the bottom of the Menu Layout window, you can see that the code itself changed as follows:
Excerpts from file schedulemenu.xml
<item android:id="@+id/donateMenu" android:title="@string/donate"  android:icon="@drawable/paypal" />

To this:
<item android:id="@+id/donateMenu" android:title="@string/donate"  android:icon="@drawable/paypal" android:visible="false"/>

The final step before recompiling the application is to change the version number in the application:

  • From the Package Explorer view, click on the ‘AndroidManifest.xml’ file. The manifest is where deployment characteristics are defined.

The Version Code is a user-defined numeric sequence.  The Version Name is a version number for the package in the form <major version>.<minor version>.<minor version variant>

  • Change Version Code and Version Name fields as follows

Add 100 to the ‘Version Code’ number
Set the ‘Version Name’ to our own, for example: 4.0.0


 Although the action of changing version code and name is optional, we are doing it to differentiate our application from the one found at the Google Play market.

  • Save your changes to the Android Manifest by selecting File -> Save.
  • Plug in your Android device

You can double check that the device is ready to accept applications by briefly switching to the DDMS perpective

  • Select Window-> Open Perspective -> DDMS

This will show your device as a row in the Devices windoweclipse_ddms_device_plugged_in

If your device does not appear, make sure that your device configuration is correct.  Here is an example of how to configure.

The final task is to deploy the modified application.

Clean the current application.

  • Select Project -> Clean

This will remove any previous compilations.
Compile in full.

  • Select Project -> Build all

Before deploying, select the Android console to monitor what will happen during deployment.

  • Click on the Console log in the lower left window and then select ’1. Android’



  • Select ‘Project -> Run’

A sequence like the following should be displayed in the Console screen:

[2012-12-18 12:57:39 -] ------------------------------
[2012-12-18 12:57:39 -] Android Launch!
[2012-12-18 12:57:39 -] adb is running normally.
[2012-12-18 12:57:39 -] Performing activity launch
[2012-12-18 12:57:39 -] Automatic Target Mode: using device '0123456789ABCDEF'
[2012-12-18 12:57:40 -] Uploading onto device '0123456789ABCDEF'
[2012-12-18 12:57:40 -] Installing
[2012-12-18 12:57:43 -] Success!
[2012-12-18 12:57:44 -] Starting activity on device 0123456789ABCDEF
[2012-12-18 12:57:45 -] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] }

At the same time, the modified Simple Loan Application should open on your device immediately.
The log shows that

  • The .apk file, the package containing the modified application was copied to the device.
  • Application installation was successful
  • The MainActivity of the application was started successfully.

This is how the modified menus in the Simple Loan Calculator should look like after deployment


This concludes this tutorial, be sure to subscribe to our RSS feed for further tutorials.


Tags: ,

Leave a Reply

= 4 + 5