Titanium Development and Android

Russell Bateman
18 October 2010
last update:

Table of Contents

Introduction
Setting up Titanium...
Here's how I solved the KitchenSink problem
Future things to check out...
That's it...
Appendix: Useful links

Introduction

This document is basically notes on starting up Titanium development.

I followed the start-up notes for Linux (and Windows). All went well enough.

I went through the four, free videos. They are only useful to show how the Titanium Developer interface works. This interface is super simple and not a great deal of help if you were expecting something on the order of what Eclipse or Visual Studio provide.

...which gives rise to the possibility that Eclipse rigged for use in JavaScript development might be a big help here.

Setting up Titanium...

Begin by going to the Appcelerator site at http://www.appcelerator.com/. Click on the "Download Titanium" link. If you're on Windows, a .msi (Windows installer) will offer itself. Look at the page, however, and you'll see instructions for getting started. It's a combination of these plus links to PDF you'll eventually encounter during the process. I'm not going to say much more about it; it's well covered by Appcelerator.com.

Later on, you'll get to downloading Android stuff if you're planning on targeting that platform. It's my main emphasis although the whole reason I'm even looking at Titanium is because I don't want to learn much about writing to the iPhone.

It's very important to install everything the Android SDK offers. Otherwise, you'll be in big trouble for making mobile apps work. See below.

Various things I've learned

Titanium apps are written in JavaScript, yes, but only as the language to use. There isn't much JavaScript going on inside: it's all calls into the Titanium APIs.

If you don't stop the application by clicking Stop in Titanium, you may have to bounce Titanium before you can get an emulator back up.

It's important to understand what's going on in the Android SDK. There are different levels corresponding to different versions of Android and the Google toolkits. In order to check to see that your application runs on older Android devices, you will need to download these other versions. Also, if you're using Titanium, you can't use the very latest Android SDK (2.2, version 8), but only 1.6.



Here's my first mobile app that does nothing, but has two tabs working.


Here's how I solved the KitchenSink problem

Sadly, the KitchenSink application failed to run. This application is crucial to early Titanium development in that it provides an example of and call to just about every API in the Titanium library. Others in the forum and elsewhere on the Internet complained, but no one gave much help as to getting it up.

Here's the distributed KitchenSink app that's supposed to show me how to call every Titanium API not working! As you can see, there is no app running on the Android emulator:

Solution

This is from my on-line post to the forum. Someone replied to try to help, but admittedly hadn't understood exactly what he had done to get his running. I don't either, but I was meticulous in my list of things I did.

  KitchenSink never comes up  

Question

I have TestDesktopApp and my own, do-nothing MobileApp running. However, KitchenSink, which strikes me as a crucial device to short-cut the Titanium learning curve, just never comes up. I've tried looking through the (emulator) device application lists, here, there, everywhere, but can't find it.

What am I doing wrong?

I'm not an iPhone guy (so, the Appcelerator tutorials, all done by Mac OS/iPhone guys, aren't totally helpful). I'm on Linux (doesn't work on Windows 7 either). I'm doing Android (am an Android developer looking at Titanium).

Answer

(Later, answering my own question...) I can't say exactly what I did, but here's all I did:

  1. Make sure you have EVERYTHING possible downloaded into Installed Packages in the Android SDK and AVD Manager. Everything that will come up. I had to keep getting stuff that would show up even after I had got everything the time before. I even brought down the Market Licensing package. I even brought down the Samples for SDK n.
  2.  
  3. Delete any and all AVDs created using the Android SDK and AVD Manager. If you can't delete one because it won't let you, make certain all consumers of AVDs are dropped (Titanium Developer and Eclipse), then Start the undeletable AVD and, as soon as you can, just click its Close box. That should be enough to let you delete it. Don't create any AVDs by hand.
  4.  
  5. Don't drop KitchenSink just anywhere. Shorten the path. I created a link in my appcelerator folder (where, for now, I've been putting all my trial projects) thus:
    $ ln -s ../appcelerator-KitchenSink-5d6e950/KitchenSink

    This might be more important to do on Windows than it is on Linux.

  6. Force rebuild of KitchenSink by touching the xml:
    $ cd KitchenSink $ touch tiapp.xml
  7. Launch Titanium Developer, remove your original KitchenSink: click on the project, then on the Edit tab, then down on the Delete Project button. Ignore what the alert says because it's gobble-dee-goop: just click the Close box (not either of the buttons whose titles don't correspond to the instructions in the alert). Be careful to do it this way in order not to lose your KitchenSink code.
  8.  
  9. Click Test & Package. Select SDK: APIs 2.2. Click Launch. Wait patiently. When you see "Welcome to Kitchen Sink for Titanium" in the INFO log window, click the Menu button in the emulator (this seems to be a peculiarity of Android 2.2: it happens when you're developing to this platform even from Eclipse).

You should be in business.

One last thing: Ignore

[ERROR] (some path)/apkbuilder" (or "apkbuilder.bat" on Windows)

It's a red herring, only a warning that the Appcelerator guys have not gone to the trouble to resolve their code doing something Android has deprecated for a while and they're posting an error about it, but it doesn't matter.


Here is the app working in the emulator now.


Future things to check out...

In future, I need to write an HTTP client and display a bit of text and an image principally. I've seen grunts and groans in the forum that suggest this is possible. Here's a list of forum entries on the questions:


That's it...

That's my proof of concept for Titanium. I'll return when I'm needing iPhone support. My desire is only to circumvent iPhone and BlackBerry programming which I'm not eager to learn. Titanium BlackBerry support is in beta since June, 2010.

Appendix: Useful links