Getting up and running on Titanium

Today I got started on the Titanium platform. Being a newbie to native mobile development, there were a couple hiccups along the way. In retrospect this would have been much easier on a Mac I’m sure, but just to make it difficult (touch of sarcasm) I tried it on Windows 7 64-bit. My goal was to set up an environment to run the Kitchen Sink demo described on the Getting Started page.

  1. I had installed the JRE and JDK at some point in the past few months to the default location C:\Program Files (x86) – this would come back to bite me.
  2. I installed Titanium Developer and the Android SDK as instructed; everything went to the default locations.
  3. I downloaded the KitchenSink project from the GitHub link provided, extracted it, imported it, and then tried to test it in the emulator. Here was the first error, described in this post. Sadly, adding C:\Program Files (x86)\Android\android-sdk-windows\platform-tools to the PATH didn’t seem to have an effect, so instead I used the hammer: I copied adb.exe from C:\Program Files (x86)\Android\android-sdk-windows\platform-tools to C:\Program Files (x86)\Android\android-sdk-windows\tools (Windows of course doesn’t have symlinks and I didn’t want to deal with a hardlink).
  4. Still errors. Next step was to install every conceivable Android SDK version (maybe that was the problem), so from the SDK manager, I installed Android SDK Tools, SDK Platform Tools, and all SDK Platform Android X.X’s.
  5. I tried to launch KitchenSink demo again, and get this error: [ERROR] JDK version 'javac' is not recognized as an internal or external command. Hmm.. According to this link, the default location for the JDK C:\Program Files (x86)\Java doesn’t work because of the spaces in the name. So I moved jsk1.6.0_21 to a different directory without spaces, and then reset my JAVA_HOME environment variable to point to this. Also had to add %JAVA_HOME%\bin to the PATH.
  6. Trying again, now I get: [TRACE] E/PackageManager( 67): Package com.appcelerator.kitchensink requires unavailable shared library com.google.android.maps; failing!. According to this post, that means I have to switch to the “APIs 2.3” SDK. That’s not an option for me so I go back to the SDK manager and install Google API’s, Android API 9 (under Third Party Add-ons). Launch Developer again and now “APIs 2.3” is an option, so I select it.
  7. Try again. That error is gone now, but now I get [ERROR] Failed installing com.appcelerator.kitchensink: pkg: /data/local/tmp/app.apk and [TRACE] Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]. Argh. At this point I am convinced that there’s some missing dependency for this sample KitchenSink project in particular, so maybe a simpler one would work.
  8. Try to create a New Project in the Titanium Developer and launch that. Success!

OK, I can now build an Android app, so I am halfway there; now on to the iOS side. I dig up an old Mac Mini, upgrade it to Snow Leopard, and install the latest XCode (3.2.5) and iOS SDK (4.2) off the Apple site. Then:

  1. Verify I can build a new project in XCode. Check.
  2. Install the latest Titanium Developer (version 1.2.2) from the Appcelerator site, which automatically installs a Titanium SDK which I would assume to be the latest (but it isn’t, read on..).
  3. Create a new Titanium project. Go to “Test and Package” tab, and the SDK poplist is hung on “loading…”. Odd – but other folks have reported this (here and here). But since I know I have a complete XCode and iOS SDK environment here, maybe it doesn’t mean anything, so I try to launch:
    [INFO] Compiling JavaScript...one moment
    [INFO] No JavaScript errors detected.
    [INFO] One moment, building ...
    [INFO] Performing full rebuild. This will take a little bit. Hold tight...
    [DEBUG] copy resources from /Users/NAME/Documents/TitaniumiPhoneSample/Resources to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp
    [DEBUG] copying: /Users/NAME/Documents/TitaniumiPhoneSample/Resources/app.js to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp/app.js
    [DEBUG] copying: /Users/NAME/Documents/TitaniumiPhoneSample/Resources/KS_nav_ui.png to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp/KS_nav_ui.png
    [DEBUG] copying: /Users/NAME/Documents/TitaniumiPhoneSample/Resources/KS_nav_views.png to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp/KS_nav_views.png
    [DEBUG] copying: /Users/NAME/Documents/TitaniumiPhoneSample/Resources/iphone/appicon.png to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp/iphone/appicon.png
    [DEBUG] copying: /Users/NAME/Documents/TitaniumiPhoneSample/Resources/iphone/Default.png to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp/iphone/Default.png
    [DEBUG] copy resources from /Users/NAME/Documents/TitaniumiPhoneSample/Resources/iphone to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp
    [DEBUG] copying: /Users/NAME/Documents/TitaniumiPhoneSample/Resources/iphone/appicon.png to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp/appicon.png
    [DEBUG] copying: /Users/NAME/Documents/TitaniumiPhoneSample/Resources/iphone/Default.png to /Users/NAME/Documents/TitaniumiPhoneSample/build/iphone/tmp/Default.png
    [DEBUG] compile checkpoint: 22.64 seconds
    [INFO] Executing XCode build...
    [INFO] Executing XCode Compiler [toggle output]
    [INFO] Compile completed in 5.984 seconds
    [DEBUG] executing command: /usr/bin/killall iPhone Simulator
    [INFO] Launching application in Simulator
    Unknown or unsupported SDK version: loading...
    [DEBUG] Simulator SDK Roots:
    [DEBUG] 'Simulator - iOS 3.2' (3.2)
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk
    [DEBUG] 'Simulator - iOS 4.0' (4.0)
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk
    [DEBUG] 'Simulator - iOS 4.1' (4.1)
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk
    [DEBUG] 'Simulator - iOS 4.2' (4.2)
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
    [INFO] Launched application in Simulator (34.06 seconds)
    [INFO] Application has exited from Simulator
  4. OK, that’s bad. So maybe iOS 4.2 isn’t supported, as someone suggested. So I look in the Titanium directories listed in that post to see what mobile SDK was installed, and it seems an old (1.2.0) version was installed, while the latest version on the Appcelerator build server is 1.6. That’s probably not a good sign, which means that whatever the latest Titanium Developer installs is not really the latest and best version.
  5. So deleted everything related to Titanium, as described in that post, tried to download and install the latest Titanium mobile SDK first off the build server. Sadly I have no idea where to install it manually and don’t see anything on the developer docs about this scenario. Dead end.
  6. I don’t see any older (and thus maybe more stable) versions of Titanium Developer anywhere on the Appcelerator site, so I installed the current version again, hoping something has changed. When I launch it, now I notice a quick popup alert that a new mobile SDK is available (1.5, not 1.6, but a lot better than the 1.2 I seem to currently have). Quickly I click that link to install it (since I didn’t see it the first time, only an alert relating to an update to the Desktop SDK which I don’t care about). I walk away and it installs. When I get back, it’s apparently installed, although I didn’t see any confirmation dialog.
  7. Now I create a project again, still get the same error as above. I restart Titanium, thinking maybe it needed to reload to get the changed SDK, and now I see a new option in the SDK poplist, for 1.5! After I select it I go to the Test and Package tab and suddenly, it’s found the iOS 4.2 SDK (as well as 4.1, 4.0, and 3.2). Much better. So I launch my project with the 4.2 SDK selected, and get this error:
    [INFO] Compiling JavaScript...one moment
    [INFO] No JavaScript errors detected.
    [INFO] One moment, building ...
    [INFO] Titanium SDK version: 1.5.1
    [INFO] iPhone Device family: iphone
    [INFO] iPhone SDK version: 4.2
    [INFO] Performing full rebuild. This will take a little bit. Hold tight...
    [INFO] Skipping JS compile, running from simulator
    [INFO] Performing clean build
    [ERROR] Error: Traceback (most recent call last):
    File "/Library/Application Support/Titanium/mobilesdk/osx/1.5.1/iphone/builder.py", line 1003, in main
    execute_xcode("iphonesimulator%s" % iphone_version,["GCC_PREPROCESSOR_DEFINITIONS=__LOG__ID__=%s DEPLOYTYPE=development TI_DEVELOPMENT=1 DEBUG=1 TI_VERSION=%s" % (log_id,sdk_version)],False)
    File "/Library/Application Support/Titanium/mobilesdk/osx/1.5.1/iphone/builder.py", line 925, in execute_xcode
    output = run.run(args,False,False,o)
    File "/Library/Application Support/Titanium/mobilesdk/osx/1.5.1/iphone/run.py", line 31, in run
    sys.exit(rc)
    SystemExit: 1

    I try all the other iOS SDK versions, same result. I think, OK, maybe the project is just shot and the “clean build” it claimed to do wasn’t good enough.
  8. So I create another project (1.5 Titanium SDK) and launch it with the iOS 4.2 SDK. This one finally compiles and builds, and for the first time I am running a Titanium iPhone app in the emulator.
  9. Now that this is working, let me see if I can duplicate the Android setup experience on the Mac as well. I confirm the JRE and JDK both version 1.6 (good enough), then download the Mac version of the Android SDK and install all the same packages as I did previously on the PC. I create a new Project, then am told that Developer cannot find my Android SDK. I navigate to the directory I put it (/Libraries/) but get this error:
    Couldn't find adb or android in your SDK's "tools" directory. You may need to install a newer version of the SDK tools..
  10. Perhaps it’s the same type of error I dealt with on the PC, so I make a symlink:
    $ cd /path/to/android/sdk/tools
    $ ln -s ../platform-tools/adb

    Then restart Titanium and try to create a new project. I got the alert saying the SDK can’t be found and so browse to the same SDK directory again, but now it can find what it needs.

  11. Launch again, using the earliest Android SDK version for simplicity (1.5) and the default HVGA screen, and get this:

    [TRACE] W/PackageParser( 633): /data/app/vmdl30760.tmp (at Binary XML file line #7): Requires newer sdk version #4 (current version is #3)
    [TRACE] D/AndroidRuntime( 696): Shutting down VM
    [TRACE] D/dalvikvm( 696): DestroyJavaVM waiting for non-daemon threads to exit
    [TRACE] D/dalvikvm( 696): DestroyJavaVM shutting VM down
    [TRACE] D/dalvikvm( 696): HeapWorker thread shutting down
    [TRACE] D/dalvikvm( 696): HeapWorker thread has shut down
    [TRACE] D/jdwp ( 696): JDWP shutting down net...
    [TRACE] D/dalvikvm( 696): VM cleaning up
    [TRACE] D/dalvikvm( 696): LinearAlloc 0x0 used 627404 of 4194304 (14%)
    [ERROR] Failed installing com.onme: pkg: /data/local/tmp/app.apk
  12. Not good. OK, now try the latest Android SDK verison (2.3) and it works, I see the app running in the emulator. Hooray!

So as I said, there were a few hiccups. But now that I have a working development environment (Android on the PC and iOS+Android on the Mac), I am really excited to get going on the Titanium platform, so kudos to the Appcelerator folks for a really ambitious undertaking. I’ll be cheering for them.

Leave a comment

Your email address will not be published. Required fields are marked *