Monday, July 29, 2013

How to create a basic Android module for Appcelerator Titanium

In Titanium  using a module we can extend the built-in functionality of the Titanium Mobile SDK. In this post I'm going to illustrate how we can create a default Hello world Android module and how to install it to your project.
First of all we need to setup the development environment. See below requirements.
- Titanium studio with Android sdk
- Download the appropriate version of Android ndk from here and extract it.
- Install Python 2.5 or above and set path for Python  in Windows system variables
- Install Eclipse jdt plugin for Titanium.!/guide/Installing_the_Java_Development_Tools

Note : Your Titanium work space name should not have spaces

Then lets see how to create the Android module using ide.
Open Titanium studio.
Select File >> New >> Mobile Module Project

In next window, enter following information

Project name: Desired project name
Titanium SDK Version: Targeted version of Titanium SDK
Deployment target: Since this is Android module select Android


Click Next to edit Module Manifest File.

Version: Version of the module.

Author, License and description, etc.

At last click Finish to create the module.
After creating the module you can see src folder under project directory. By default there are two java classes and
Open under the platform directory

By default that configures for the paths of


You need to include path for Android ndk there. ie the location where you extracted the ndk archive. Add following line to
android.ndk = C:\\android_ndk\\android-ndk-r8e

Then right click on Build.xml and select Run As Ant Build

After complete the build process finally you should be able to see BUILD SUCCESSFUL message.

Then let's see how can we install created module in to Android Titanium project.
First of all Create new mobile project.(File >> New >> Mobile Project)

In next window select Classic from left side pane. Then select Default Project and click Next.

Fill Project name and app id fields. Select Android as Deployment target. Finally click Finish to create the project.

Next we need to install the created module in to our project. Open the module from project explorer. And open “dist” folder. In dist directory you can find the module in zipped  and jar formats.

Copy and paste the zipped archive to the root of your newly created project.

Then open tiapp.xml in xml view

Add following lines after the </mobileweb> tag to add and register the module.
        <module platform="android" version="1.0"></module>
Here give same module version and module id as you provided when creating the module. Then press ctrl + s to save the change to Tiapp.xml. And test run the project on emulator. Make sure that your project is running without any module related errors.


No comments:

Post a Comment