Home > Android > Quickstart Android 4.0 mobile app development

Quickstart Android 4.0 mobile app development

It probably does not come as a surprise to you that mobile devices & mobile apps are hot. As more and more new mobile devices like smartphones and tablets come to market, the demand of apps increases as well. In 2011 the mobile devices market growth (tablets in particular) has exceeded the pc market growth by far. Based on the statistics of onlinemarketing-trends.com almost half of the smartphones sold in 2011 run Google Android. This post will focus on the Android platform and will give you a few easy steps for setting up, building and deploying a basic Android project using Maven and the Android SDK.

Installing and configuring the Android SDK

The Android SDK contains tools and sample code for developing Android apps.

Install the Android SDK

To install the SDK follow the next three steps:

  • Download the sdk zip file from here: http://developer.android.com/sdk/index.html and unzip the file.
  • Create a new environment variable ANDROID_SDK pointing to the root of the exploded zip directory (used by maven) and extend your environment variable PATH by adding ANDROID_SDK/tools and ANDROID_SDK/platform-tools (in order to find the SDK executables).
  • Test if all SDK commands can be run from anywhere in your OS console/shell. Open a new console and try if the following command works: adb version.

Configure the Android SDK

In order to use the SDK you need to configure it. This can be done by:

  • Run the following command (plain and simple:) in the console: android
  • Check the complete folder Tools and from the Android version(s) you want to support expand the folder and check the SDK Platform.
  • Click on the ‘install packages’ button.


Create, build, deploy and run a basic android application

To quickly setup a basic maven project, the maven Maven-Android-Archetypes will be used.
Navigate to the folder where you want the create the project and set up the project by running the command below.
Do notice that the value for the platform option must match the API version of the SDK you have installed (in this case 15).
You can change the groupid and artifactid if you like before running it. While running just hit enter two times to complete the creation of the project.

mvn archetype:generate \
-DarchetypeArtifactId=android-quickstart \

-DarchetypeGroupId=de.akquinet.android.archetypes \
-DarchetypeVersion=1.0.7 \
-DgroupId=your.company \

-DartifactId=my-android-application \
-Dplatform=15

Change your dir location to the root of  ‘my-android-application’ folder.
The project is ready to be build and to be deployed to your mobile device*. The install argument will create an .apk deployment in the target directory. The android:deploy argument will use the android SDK to actually deploy this .apk to your device. Connect it via usb and run the following command:

mvn clean install android:deploy

There you go. The app is installed! Check your device. It should contain a new app called ‘my-android-application’ . When running it, it will show you a plain nice hello message.

* If you should not have a device running the Android OS, you can alternatively configure and run the Android emulator. See the section Android emulator and SDK tools on how configure it. The installation / deployment step mentioned above will be the same for an emulator.

Integration of Android SDK into your IDE

If you want to integrate the Android SDK with one of the following IDEs then install the mentioned plugin:

Android emulator and SDK tools

Running the Android emulator

When you do not have a mobile device or just want to run the Android emulator, you have to create an Android Virtual Device (AVD)..
In order to do this follow these steps:

  • Run the android command again.
  • If the Android API is 14 or higher (4.0 and up) then install from the same Android version, select the ARM EABI 7a System Image (check box below the SDK) and install it.*
  • Run android list targets to list all available Android targets.
  • android create avd -n -t (name is the logical name of AVD to be created, id is the target id of one of the Android targets from the previous step).

Now that you have created an AVD lets run it the emulator. Do know that API 14 and up may take some time to load.

  • emulator -avd <avd-name>

Other interesting SDK commands

Show running devices (mobile devices as well as emulators): adb devices
Install an apk deployment (-s is optional): adb install
Remove app from device: adb uninstall
Run adb help for more information.

*If you don’t execute this step for these APIs then you will get the following error when you try to create an AVD:
Valid ABIs: no ABIs.
Error: This platform has more than one ABI. Please specify one using –abi.

More info on Android app development

To get more info on Android development a lot of resources are available. A good starting point would be developer.android.com in particular the dev guide section and the tutorial resource section. In addition I recommend the following resources:

Amongst others these books contain more on Android as well:

  • Professional Android Application Development – Reto Meier
  • Unlocking Android – W. Frank Ableson, Charlie Collins, and Robi Sen
  • Hello, Android  – Ed Burnette
About these ads
Categories: Android Tags: , , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 206 other followers