# Android Titanium SDK Development Setup
This is a guide to setup the Android development environment to develop for Titanium Mobile.
# Getting started
ADT has been discontinued and we don't recommend using it.
Make sure you have the environment setup to build Titanium Mobile: Building the Titanium SDK From Source
Download Eclipse IDE: http://www.eclipse.org/downloads/ (opens new window)
After download finishes, unzip and run it. You'll need to create a new workspace if you don't have one already.
Uninstall CDT plug-in if you have it installed in Eclipse. Our setup will not work with CDT.
Install ADT by following the instruction on http://developer.android.com/sdk/eclipse-adt.html#installing (opens new window)
- If you see a warning message of "installing unsigned content" during installation, click OK
Restart Eclipse after installation complete.
# Set up Eclipse environment
After completing the getting started section:
Import Projects by launching Eclipse and go to File > Import > General > Existing Projects into Workspace.
Click Browse, then go into this directory:
- Note: this path will vary (depends on where you clone the directory).
Now you should see a number of projects under
Projectsdirectory. You can enable "Copy projects into workspace", but I prefer not to, b/c if this is enabled, every time you pull from master, or rebuild titanium_mobile, your eclipse workspace will not get updated.
Create a Java project named
titanium-distby navigating to File > New > Java Project.
After you name the project, click Finish.
titanium-distand link it with
titanium_mobile/dist/androiddirectory. Right-click on titanium-dist project and go to New > directory > enter name. Next, click Advanced > select Link to Alternate Location > Browse > select
titanium_mobile/dist/androiddirectory (titanium_mobile is the directory you cloned from above).
Run SCons from terminal, then refresh your workspace. At this point, you should NOT see any errors. If you see odd errors, regarding DDMS or similar, try restarting Eclipse/ADB.
- NOTE: If you encounter an error to do with ANDROID_NDK not found, go to Eclipse > About Eclipse > Installation Details, and remove the Android Native Development item.
# Create test projects in Eclipse
After the Eclipse environment is set-up, we are now ready to create a test project in Eclipse for debugging purposes.
Create a new Android project named TitaniumTest:
File > New > Project... > Android > Android Project.
Click Next > Select Google API 2.2 (API 8). Note: you may see two copies of the google APIs, pick one.
Hit Next > enter Package Name:
Create a new Titanium Project via Titanium Studio with the exact same credentials:
File > New > Titanium Mobile Project.
TitaniumTest, with the app Id:
src/com.titanium.test/, rename the class
TitaniumtestActivity.java. If Eclipse doesn't automatically update the classname, update it yourself. (This is necessary for the generated files in the next step.)
Run the project you just created via Titanium Studio on an Android device/emulator. This should generate a build directory in your Filesystem.
Navigate to the Filesystem: Build > Android > gen > com > titanium > test.
Copy all the
.javafiles except for
R.javaover to your Eclipse project. These files go to src/com/titanium/test on your Filesystem.
Replace the contents of your
AndroidManfiest.xmlin Eclipse with the one in Titanium Studio, precisely build>Android>AndroidManifest.xml. If you see any errors like missing themes or icons, just delete those fields from your xml.
In your Eclipse Filesystem, create a directory named
/assets, and copy Resources directory from your Titanium Studio project to
/assets/Resources. Creating a symlink between two directories will not work.
In your Eclipse project, add necessary libraries to it. You can do this by right clicking on the project, go to Properties > Android, then under the Library section, click Add on the right side. You should see a list of options, add ALL of them (you can only add one at a time). This won't actually work anymore with the latest Android SDK. The problem is that you won't be able to breakpoint in the Library project. In your Eclipse project, add necessary libraries to it: go to Properties > Java Build Path > Projects. Add all the Titanium projects. Now go to the next tab "Libraries". Add JARS... select all the projects libraries (each time under bin directory). You have to do them one by one. Finally go to the last tab "Order and Export", Select all the titanium projects + jars
- If you updated to ADT 22, there's an existing bug that will cause Eclipse environment to stop working. Here's the link to the issue: https://code.google.com/p/android/issues/detail?id=55304 (opens new window). To fix this, right-click on the project you want to run (NOT the library projects), Properties > Java Build Path > Order and Export > check Android Private Libraries box.
In your Eclipse project, locate
TitaniumtestApplication.java, and remove the content inside
verifyCustomModulesmethod, but DO NOT remove the method.
Refresh your workspace, full clean, and re-build.
Run/Debug the project.
# Setting up IntelliJ IDEA environment
Download and install IntelliJ IDEA here: https://www.jetbrains.com/idea/download/ (opens new window)
Import Projects > Select your source (
~/Titanium_Mobile/android) > choose Eclipse box, and hit Next.
Make sure format is
.ideaand hit Next > Now. All the projects should be selected and you want to unselect the
TitaniumTestprojects. Then hit Next.
Select Android 6.0 SDK and click Finish.
- Note: if this is your first time running InteillJ, you may need to set Android home path. If you don't see Android 6.0, you'll need to install Android 6.0.
Now you may see a "Locate Eclipse Information" dialog window, click Cancel. A dialog window called "Import from Eclipse" may pop up in which case you click Cancel. This will result in an error says unknown JDKs. If you're seeing this, one or more projects imported is using the JDK that is not configured in IntelliJ. For instance, if you have JDK 1.7 on IntelliJ, and kroll-apt project is using 1.6, you'll see this. Click Ok for now.
Now you may see the dialog window "Import Android dependencies from property files", check all, and click Ok.
This step assumes you have JDK 1.7 configured on IntelliJ. Do a quick Build > Make Project. You should see the error "Cannot start compiler... SDK is not specified for module kroll-apt". Click Ok, this should take you to Project Structure of kroll-apt, where you'll see "JavaSE-1.6" and "ECLIPSE" boxes red. Remove ECLIPSE by right-clicking and selecting remove. Then change "Module SDK" to 1.7.
In the same window, go through each module and remove
com.android.ide.eclipse.adt.DEPENDENCIES. Click Ok once you're done.
Right-click on titanium module > Open Modules Settings > Remove "kroll-apt.jar" > click on the "+" button at bottom left corner, choose Module Dependencies, then choose "kroll-apt". Now check the export box for
android-support-v7-appcompat. Now change the scope of
android-support-v7-cardviewto "Provided". Then go to each modules, and remove
Build > Rebuild Module. It should compile successfully. If the build fails due to map, right-click the map module > Open Module Settings, and make sure the Module SDK is "Android 6.0 Google APIs".
# Create test projects in IntelliJ
These steps assumes you already have a working test project for Eclipse, if not please follow the procedure for creating one above.
Import your Eclipse project over: File > New > Module from existing sources. For first timers, import
Right-click on your newly imported module, go to module settings, click on the "+" button on the bottom left, select "Module Dependency" and add everything on that list EXCEPT for
Run SCons if you haven't already. Forgetting to run SCons will result in runtime error. To run SCons for Titanium SDK versions 5.4.0+, navigate to
titanium_mobile/builddirectory then run this in the terminal:
npm install && node scons.js build && node scons.js package && node scons.js install. Ensure you have latest stable version of Node and npm installed for this to work.
Go to Build > Rebuild Project.
# Setting up InteliJ IDEA environment on Windows
# Environment variables
ANDROID_SDK - Location of Android SDK with no spaces:
ANDROID_NDK - Location of Android NDK with no spaces:
ANT_HOME - Location of Ant:
JAVA_HOME - Location of JDK:
(C:\Program Files (x86)\Java\jdk1.8.0_102\)
# Importing Android Titanium project into InteliJ
# Fix dependencies
Right-click on the
androidproject and click Open Module Settings.
Click the "+" to add a New Project Library, and click Java.
titanium\lib\aps-analytics.jarand click OK.
Add this library to app, locale, network, and platform modules.
In the library list you should also see
lib3, right-click, and select Add to Modules....
Add this library to
gesture map, and
lib1, and select Add to Modules....
Add this library to TitaniumTest.
# Compiling kroll-v8 on Windows
# Additional Requirements
Download the binaries, rename gzip into gunzip and place both into
Open a command prompt and navigate to
node scons.js build
For formatting, we follow Android's formatting style. You can follow the eclipse formatting rules at https://source.android.com/source/using-eclipse.html#eclipse-formatting (opens new window).
You can download the formatting file here: android-formatting.xml