Sencha Touch 2 Native Packaging for Android

Requirements

Software

- Android SDK Tools (Revisions 13+)
- (Optional) Eclipse

Steps to package your Android application

1. Prerequisite: an appropriate Android ready certificate (debug or release) for signing the application
2. Install Sencha SDK Tools (SenchaSDKTools 2.0).
3. Create a packaging configuration file to be use with the packager.
4. Run the packager to create a packaged <application>.apk.

Step 1: Android certification generation

Android Keytool included in the Android SDK tools is one way of creating certificate for signing Android applications. Below is an example of a Keytool command that can generate a private key:

?

`$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize` `2048` `-validity` `10000`

Please follow the steps on the Android developers guide “Signing Your Applications” for more information about creating certificates and signing applications.

Step 2: Install the Sencha SDK Tools.

- Run the Sencha SDK installation: SenchaSDKTools (SenchaSDKTools-2.0.0-Beta)
- The sencha command that includes the package option will be installed to the specified location during installation (default: Applications/SenchaSDKTools-2.0.0-Beta/command).

Step 3: Create a packaging configuration file to be used with the native packager.

The configuration file has the following format:

?

`{` `` `"applicationName"``:``"<AppName>"``,` `` `"applicationId"``:``"<AppID>"``,` `` `"outputPath"``:``"<AppPackageOutputPath>"``,` `` `"iconName"``:``"<AppIconName>"``,` `` `"versionString"``:``"<AppVersion>"``,` `` `"webAppPath"``:``"<PathToWebApp>"``,` `` `"configuration"``:``"<Release | Debug>"``,` `` `"platform"``:``"<Android | AndroidEmulator>"``,` `` `"certificatePath"``:``"<certificatePath>"``,` `` `"certificateAlias"``:``"<certificateAlias>"``,` `` `"sdkPath"``:``"/android-sdk-mac_86"``,` `` `"orientations"``: [``"portrait"``,` `` `"landscapeLeft"``,` `` `"landscapeRight"``,` `` `"portraitUpsideDown"` `` `]` `` `"deviceType"``:``"<Not applicable for Android>"` `}`

Note: A configuration file template can be created by running the following command:

?

`sencha` `package` `generate <configTemplate.json>`

<configTemplate.json> is the name of the configuration template file.

Note: the <configTemplate.json> path or filename cannot contain any space.

The following parameters are applicable to Android packages:

Parameters | Details
"applicationName":"<AppName>" | The application name of your application. The output file will have this name <AppName>.apk
"applicationId":"<AppID>" | An ID given to your application. Suggestion to use a nameSpace for your app. E.g. com.sencha.Touch2Package
"outputPath":"<AppPackageOutputPath>" | The output location of the packaged application, <application.apk>.
"iconName":"<AppIconName>" | The launcher icon file to be used for your application. Note: Please refer to the AndroidLauncher Icons guide for further information on icon file specifications.
"versionString":"<AppVersion>", | The version of the application.
"webAppPath":"<PathToWebApp>" | The path of the web application to be packaged.
"configuration":"<Release | Debug>" | Specify build type: Release or Debug.
"platform":"<Android | AndroidEmulator>" | Specify if the build is for the Android device (Android) or the Android Emulator (AndroidEmulator).
"certificatePath":"<certificatePath>", | Specify a specific Certificate location for the certificate used for signing your application.
"certificateAlias":"<CertificateAlias>" | Specify a specific Certificate Alias to use for signing your application.
"orientations": ["portrait", "landscapeLeft", "landscapeRight", "portraitUpsideDown" | (Optional) Specify the orientations of the application. Available options: “portrait”, “landscape”, “landscapeRight” and ”portraitUpsideDown” Note: this is an optional parameter. If omitted, the default value used is all 4 orientations mode.
"devicetType" | This is not applicable for Android application. This config parameter is ignored when building an Android application.

Sample debug configuration file

?

`{` `` `"applicationName"``:``"SenchaTouch2Package"``,` `` `"applicationId"``:``"com.sencha.Touch2Package"``,` `` `"iconName"``:``"icon.png"``,` `` `"versionString"``:``"1.0"``,` `` `"outputPath"``:``"~/Desktop/STBuild-Android"``,` `` `"webAppPath"``:``"~/Desktop/www/"``,` `` `"configuration"``:``"Debug"``,` `` `"platform"``:``"Android"``,` `` `"deviceType"``:``"Universal"``,` `` `"certificatePath"``:``"~/Desktop/debug.keystore"``,` `` `"certificateAlias"``:``"androiddebugkey"``,` `` `"sdkPath"``:``"~/Desktop/android-sdk-mac_x86"``,` `` `"orientations"``: [``"portrait"``,` `` `"landscapeLeft"``,` `` `"landscapeRight"``,` `` `"portraitUpsideDown"` `` `]` `}`

Sample release configuration file

?

`{` `` `"applicationName"``:``"SenchaTouch2Package"``,` `` `"applicationId"``:``"com.sencha.Touch2Package"``,` `` `"iconName"``:``"icon.png"``,` `` `"versionString"``:``"1.0"``,` `` `"outputPath"``:``"~/Desktop/STBuild-Android"``,` `` `"webAppPath"``:``"~/Desktop/www/"``,` `` `"configuration"``:``"Release"``,` `` `"platform"``:``"Android"``,` `` `"deviceType"``:``"Universal"``,` `` `"certificatePath"``:``"~/Desktop/senchatouch-key.keystore"``,` `` `"certificateAlias"``:``"senchatouch"``,` `` `"sdkPath"``:``"~/Desktop/android-sdk-mac_x86"``,` `` `"orientations"``: [``"portrait"``,` `` `"landscapeLeft"``,` `` `"landscapeRight"``,` `` `"portraitUpsideDown"` `` `]` `}`

Step 4: Run the packager to create a packaged <application>.apk

Packaging a debug application and run it on an Android Emulator

Prerequisite: The Platform and Configuration setting needs to be set in the config file.

Example:

“platform”:”AndroidEmulator”

“configuration”:”Debug”

To package a debug application to run on the Android Emulator:

- Start the Android Emulator
- Issue the following command:

?

`sencha` `package` `run <configFile.json>`

Note: the application will start in the already running Android Emulator after successful executing this command. If Android Emulator is not started before issuing the command, Android Emulator will not start automatically. If package is successful, an <AppName>.apk is available in the application output location for you to manually test it on an Android Emulator or a device.

More info about Android Emulator can be found on the Android Developer Guide: Using the Android Emulator.

Packaging the application for distribution

To package a signed application to run on the device, issue the following command:

?

`sencha` `package` `<configFile.json>`

Note: an <AppName.apk> is created in the specified output location. This is the application that you can use to release for distribution.

See Also

1. Signing Your Applications
2. Installing the ADT Plugin for Eclipse
3. Eclipse
4. Managing Virtual Devices for Android Emulator