Monday, October 25, 2010

Go Public with Your Android Application: Signing and Deployment (Part 1)

So far, you've been learning about the interesting things you can do with Android. However, if you want your application to see the light of day and run on other users' devices, you need a way to distribute your application and deploy them onto your target devices. This article will show you how to prepare your Android applications for deployment and get them onto your customers' devices.


Creating the Sample Application
A simple Android application will illustrate deployment on an Android device. So, using Eclipse, create a new Android project.

Versioning
Beginning with version 1.0 of the Android SDK, the AndroidManifesl.xml file of every Android applications include the android:versionCode and android:versionName attributes:


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.myapp"
      android:versionCode="1"
      android:versionName="1.0.0">
    <application android:icon="@drawable/icon" 
        android:label="@string/app_name">
        <activity android:name=".Main"
                  android:name ="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
The android:versionCode attribute represents the version number of your application. For every revision you make to the application, increment this value by 1 so that you can programmatically differentiate it from its previous version. This value is never used by the Android system, but it's useful as a way to obtain the version number of an application. The android:versionName attribute contains versioning information that is visible to the users. It should contain values in the following format: <major>.<minor>.<point>.
If you are planning to publish your application on the Android Market, the AndroidManifest.xml file must have the following attributes:
  • android:versionCode
  • android:versionName
  • android:name
  • android:name
In addition, if your application needs a minimum version of the SDK, you can specify it in the AndroidManifest.xml file using the element, like this:


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="net.learn2develop.MyKillerApp"
      android:versionCode="1"
      android:versionName="1.0.0">

    <uses-sdk android:minSdkVersion="5" />

    <application android:icon="@drawable/icon" 
        android:label="@string/app_name">
        <activity android:name=".MyKillerApp"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
As the current version of the SDK is 1.0, there is no necessity for you to specify the minimum version of the SDK required. 



Your Ad Here