Appcelerator Developer Blog

Titanium SDK/Studio 3.1.0 Beta Now Available

We’re very excited about our newest release of Titanium—version 3.1.0. Today we release a beta of both SDK and Titanium Studio—the newest version of our Titanium platform. This release focuses on performance. Not only are we introducing the successor to TableView in ListView, we’ve made the whole iOS and Android platform faster.

How much faster?

  • Our new component, ListView, is multiple times faster than TableView
  • On iOS, we have an average 20% performance gain from 3.0.0 for the entire platform
  • On Android, we have an average 36% performance gain from 3.0.0 for the entire platform

In short, your apps should run better and faster under 3.1.0. Read on below, and for full information, please see the release notes.

Note: This is a beta release, and as such may contain regressions or other issues. Please do not use it in production, and keep backups of all important projects and data. We will follow with additional releases in the coming weeks. If you find an issue, please report it in JIRA with a reproducible test case.

How to Update

These are links to continuous integration builds. To install them, choose “Help Menu > Install Specific Titanium SDK…” from inside Titanium Studio.

To update Studio, please visit http://preview.appcelerator.com and follow the instructions to update to the RC stream, or to download a new install.

NPM Packages

Note: You may need to use ‘sudo’ before these terminal commands on OSX and Linux
npm install -g alloy@1.1.0-beta
npm install -g titanium-code-processor@1.0.0-beta
npm install -g titanium@3.1.0-beta
To revert back to stable versions:
npm remove -g titanium
npm install -g titanium
npm remove -g alloy
npm install -g alloy
npm remove -g titanium-code-processor
npm install -g titanium-code-processor

New Features in Titanium 3.1.0

The docs are all available at: http://docs.appcelerator.com/titanium/latest/

ListView

This release introduces ListView, a new Titanium proxy to replace the existing TableView. Both list view and table view present data to user as a vertically scrolling list of rows. However, list view uses a data-oriented approach versus table view’s view-oriented approach.

Alloy Updates

New collection binding functionality has been added. You can now also get Alloy content assist and debug Alloy applications inside Titanium Studio.

EventKit UI Framework

The iOS EventKit framework, allowing access to calendar events and reminders, is now available inside Titanium.

iOS6 Core Location AutoPause API

The iOS AutoPause API pauses the location updates when an application goes into the background. We’ve implemented access to this new API in Titanium.

iOS Retina simulator support

The iOS simulator now allows you to choose to launch in Retina mode on demand, rather than needing to switch the simulator manually.

A Slimmer Titanium Studio

We’ve been working on making Titanium Studio as lean as possible. One step we’ve taken is to break the server-side language plugins (PHP, Ruby and Python) into separate optional installs. If you need them, just follow the links at http://preview.appcelerator.com to add them back in.

New Platforms

BlackBerry

Our BlackBerry support will go into beta at the same time as 3.1.0 ships. Studio now supports creating projects as well as running them on simulator and device.

Tizen

Our newest platform, Tizen, is now a full member of the Titanium family. Use Tizen from inside Studio 3.1.0. Create projects and run on emulator and device.

New Modules

Facebook V3 (Android and iOS)

Our Facebook module is now updated to be compatible with the latest V3 version of the Facebook API. Download the updated beta module here: Android and iOS.

Google Maps V2 (Android)

As mentioned previously, we’ve updated our Android maps module to support Google Maps V2. Download the latest beta here.

Newsstand (iOS)

Publish a magazine or periodical! We’ve developed a new module for interfacing with Apple’s Newsstand service. Download the beta module here.

NFC (Android)

You can now read NFC (Near-Field Communication) tags from inside Titanium applications. Download the beta module here.


Configuring Appcelerator Titanium to Use Intel x86 Images

Today’s guest post and cool Android emulator optimization tip comes from Titanium developer Mark Burggraf. Thanks for handy tips, Mark!

If you have used Titanium to develop for Android, you know that the Android Emulator can be slow. The reason for this is that the Android Emulator is actually launching a virutal machine for the ARM architecture to run your app, and this is running on top of your computer which uses an x86 architecture. This post guides you through the process of configuring your Android Emulator to run as x86, resulting in a dramatic increase in performance and a much smoother development cycle.

Configuring Appcelerator Titanium to Use Intel x86 Images

(A.K.A. “How to make working with the Android Emulator bearable.”)

If you follow these instructions, you’ll end up with an Android Emulator optimized for the x86 platform that runs as fast as your iOS Simulator (once it finally boots up.) This x86 version of the emulator boots faster, runs faster, and restores your sanity when working with Android.
NOTE: many (maybe most?) Titanium custom modules will not work with the x86 emulator. If you rely on a lot of third-party custom modules, you may be out of luck. Contact the module developers and ask them if they’ll support the platform with x86 libraries.

IMPORTANT Assumptions:

We assume here that:

  1. You’ve got a true Apple Mac running OSX 10.8.3. (Other versions of OSX may work just fine, but we’ve only tested 10.8.3.)
  2. You have Appcelerator Titanium Studio installed. If not, go to http://www.appcelerator.com and get it — it’s free, and it rocks.
  3. You have the Android SDK installed and working with Titanium Studio. If not, follow the guides on the Appcelerator site to get it working.

This tutorial isn’t about getting Titanium working with the Android emulator. We’ll assume you already have that working. This tutorial is about getting Titanium to work BETTER AND FASTER with the Android emulator. Or, rather, just getting the Android emulator to work BETTER AND FASTER.

STEP 1

Find your Android SDK location. If you already know where your Android SDK is installed, you can skip this step.

  1. Open Titanium Studio
  2. Click in the menu at the top: Titanium Studio / Preferences
  3. In the Preferences screen:
  4. Click Titanium Studio / Titanium
  5. Look under Android / Android SDK Home
  6. Make a note of this path — this is your Android SDK Root Path

In Step 2, wherever you see /path/to/android/sdk you’ll want to replace it with your own Android SDK path

STEP 2

Set your ANDROID_SDK_ROOT variable and create symbolic links.

Open a terminal window. Type the following (using the path from Step 1):

export ANDROID_SDK_ROOT=/path/to/android/sdk >> ~/.bash_profile

IMPORTANT NOTICE: If you have spaces in your path, you’ll need to escape each space with a backslash. Let’s say you put your Android SDK in the path “/Applications/Titanium Studio/Android SDK”. You’ll need to do this:

export ANDROID_SDK_ROOT=/Applications/Titanium\ Studio/Android\
SDK >> ~/.bash_profile

Close the terminal window and open a new terminal window. Your ANDROID_SDK_ROOT variable should now be set!

To make your life easier, we’ll now set up some symbolic links to the import Android command-line utilities. Once again, if you have spaces in your Android SDK path, you need to put a backslash before each space:

$ sudo ln -s /path/to/android/sdk/tools/android /usr/bin/android
$ sudo ln -s /path/to/android/sdk/tools/emulator /usr/bin/emulator
$ sudo ln -s /path/to/android/sdk/platform-tools/adb /usr/bin/adb

STEP 3

Install the Intel Hardware Accelerated Execution Manager for your platform

Launch the Android SDK Manager from the terminal window by typing:

android

Under “Extras”, check the box for “Intel x86 Emulator Accelerator (HAXM)”. Click the “Install package(s)” button and complete the installation. While you’re in the SDK Manager, make sure you have one or more x86 images installed under the Android Platform(s). For example, if you’re using Android 4.0.3 (API 15), look under that folder to make sure “Intel x86 Atom System Image” is installed. You’ll want the x86 image installed for each platform that you want to test.

STEP 4

Install the HAXM hot fix from Intel.

Go to the page: Intel® Hardware Accelerated Execution Manager 1.0.1 (R2)

In the “Mac OS X” section, download and install:

extra_intel_haxm-macosx_r02.zip

then download and install:

release_1.0.4-hotfix

STEP 5

Create a new Android Run Configuration for your Titanium project.

  1. Go into Titanium Studio.
  2. In the Project Explorer window, right-click on your project’s root entry (on the project’s name):
  3. Select Run As / Run Configurations
  4. Click “Titanium Android Emulator” in the tree
  5. Click the “Launch New Configuration” button (at the top left of the tree.)
  6. Under Android API, select an [x86] platform. For our example, we choose: Android 4.0.3 [x86]
  7. For this example, select Screen: HVGA
  8. Under Project, click Browse and select your project.
  9. Name your new configuration at the top. For our example, we name it: MyProject Android 4.0.3 [x86]
  10. Click Apply
  11. Click Run
  12. Wait for the emulator to start up completely and run your project. (Your project may not run if it requires Google API libraries — this is ok — we’ll add them back in later.)
  13. Make a note of the emulator instance name (shown at the top of the emulator window). It will look like this: titanium_16_HVGA_x86
  14. Close the emulator.

STEP 6

Configure your new Android Emulator instance.

Launch the Android Virtual Device Manager. Back in the terminal window, type:

android avd
  1. Click on your emulator instance from Step 5, then click Edit.
  2. Here, we’re going to configure this emulator to look and work like a real Android phone.
  3. Select the “Resolution” radio button and enter a resolution of 320 x 528 (allowing 40 pixels at the bottom for the hardware buttons.)
  4. Under “Hardware” at the bottom:
  5. Click New.., Select GPU emulation, Click OK
  6. Click New.., Select Hardware Back/Home keys, Click OK
  7. Click New.., Select Ideal size of data partition, Click OK
  8. Click New.., Select Keyboard support, Click OK
  9. Click New.., Select SD Card support, Click OK
  10. Now change the following values:
  11. SD Card Support: yes
  12. Hardware Back/Home keys: no (this puts the back/home keys at the bottom of the screen)
  13. Keyboard Support: yes (this allows you to type from your computer keyboard when in the emulator)
  14. Device ram size: 512 (this should be the default, but you can adjust it here)
  15. GPU emulation: no (you can change this to “yes” and see if it works for you later)
  16. Click “Edit AVD”
  17. Close the Android Virtual Device Manager.

STEP 7

Manually edit the emulator configuration file.

This step is necessary due to a bug in the Android Virtual Device Manager app. We want to adjust the “Ideal size of data partition” but we can’t do that in the Android Virtual Device Manager for some reason, so it must be done manually. Why adjust the size of the data partition? Because, in the development cycle, every time you run a new version of your application, the data partition begins to fill up. After a few runs of your app (sometimes after just 2 runs) you get an “out of space” error when you try to run the app. It’s easy to fix — you just go into the emulator, go into settings, go to Apps, find your app, then delete your app, then try running your app again from Titanium Studio. This is time consuming, though, and you lose any data you’ve entered in your app. Increasing the size of the data partition allows you to run your app many, many more times before you have to delete it and start again.

Make a note of your emulator instance name from Step 5, such as “titanium_16_HVGA_x86″.
We’re going to edit a text file now — if you have an editor configured, or you prefer nano or vi or something else, go ahead and use that. We’ll assume here you’re clueless, but that you know how to use Textedit.

In the terminal window, type:

$ open -a TextEdit ~/.android/avd/<>.avd/config.ini

For our example, it would be:

$ open -a TextEdit ~/.android/avd/titanium_16_HVGA_x86.avd/config.ini

Change the line:

disk.dataPartition.size=0 to disk.dataPartition.size=512m

This gives a 512mb data partition. Save the file and exit TextEdit.

STEP 8

Copy the Google APIs to your emulator instance.

In the terminal window, start the Android Virtual Device Manager:

android avd &

(Why is there an & at the end of the line? So that this command runs in the background and we get a terminal prompt back.)

  1. Click New…
  2. Under AVD name, enter something like “Google_API_15_Template”
  3. Under Target, select Google API’s (Google Inc.) — API Level 15 (the API level must match the API level you selected in Step 5. For Android 4.0.3, the API level is 15.
  4. Under Device, choose any device (we’ll use an HVGA device here…)
  5. Click OK, then OK
  6. Select your new device “Google_API_15_Template”, then click Start, then click Launch
  7. Wait for the new emulator instance to completely boot.
  8. Once the new emulator instance is running, go back in the terminal window and type:

    $ cd ~
    $ adb pull /system/etc/permissions/com.google.android.maps.xml
    $ adb pull /system/framework/com.google.android.maps.jar
    

  9. Exit the emulator. Exit the Android Virtual Device Manager.
  10. Now, we copy the Google APIs to the new emulator instance (from Step 5)
  11. In the terminal window, type:
    $ emulator -partition-size 512 @<> &

    For our example, it would be:

    $ emulator -partition-size 512 @titanium_16_HVGA_x86 &
    

    (Note: the above command will fail if your ANDROID_SDK_ROOT variable is not set correctly from Step 2.)

  12. Once the emulator boots (and it should boot much faster than the Google API Template instance), type this in the terminal window:
    $ adb remount
    $ adb push com.google.android.maps.xml /system/etc/permissions
    $ adb push com.google.android.maps.jar /system/framework
    
  13. Don’t close the emulator just yet — we’ll use it again in Step 9.

STEP 9

Build a system image

Download mkfs.yaffs2.x86 from here:
https://code.google.com/p/android-group-korea/downloads/detail?name=mkfs.yaffs2.x86

Copy the mkfs.yaffs2.x86 file to the emulator. In the terminal window, type:

$ adb push [[path]]/mkfs.yaffs2.x86 /data

You probably downloaded mkfs.yaffs2.x86 to your ~/Downloads folder, so it would look like this:

$ adb push ~/Downloads/mkfs.yaffs2.x86 /data

Now create the new system image by typing:

$ adb shell chmod 755 /data/mkfs.yaffs2.x86
$ adb shell /data/mkfs.yaffs2.x86 /system /data/system.img

Pull the newly built image to the current folder (This step takes a VERY LONG TIME):

$ cd ~
$ adb pull /data/system.img

Now copy the new image to your avd folder:

$ cp system.img ~/.android/avd/<>.avd/

For our example, it would be:

$ cp system.img ~/.android/avd/titanium_16_HVGA_x86.avd/

Now close the emulator – you’re done!


Correcting a Bug in the Latest Google NDK r8e

In our continuing effort to inform you of ecosystem issues as we encounter them, the latest NDK toolchain update from Google contains a bug. This causes an issue when building the Titanium Mobile SDK from source. The fix is trivial, and is only necessary if you’ve updated to NDK version r8e, released March 21st, 2013 and are building Titanium Mobile using SCons.

To perform the fix, edit the file build/core/build-binary.mk under the Android NDK directory, replacing line 49:

$(cleantarget): PRIVATE_CLEAN_FILES := ($(my)OBJS)

With this:

$(cleantarget): PRIVATE_CLEAN_FILES := $($(my)OBJS)

The following output from “scons android” (when building titatitanium_mobile) is a symptom of the problem:
     [exec] rm -f src/native/../../generated/*
     [exec] rm -rf src/native/../../obj/*
     [exec] Clean: kroll-v8 [armeabi]
     [exec] rm -rf (TARGET_OBJS)
     [exec] /bin/sh: -c: line 0: syntax error near unexpected token `(‘
     [exec] /bin/sh: -c: line 0: `rm -rf (TARGET_OBJS)’
     [exec] make: *** [clean-kroll-v8-armeabi] Error 2

 

More information can be found here:

https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/3wIbb-h3nDU

There is a second issue that only affects Max OS X developers using the 64-bit NDK (i.e. the download with the file name android-ndk-r8e-darwin-x86_64.tar.bz2). The fix is trivial and requires you to make the following one-line changes to these two files:

${ANDROID_NDK}/ndk-build: Replace line 158:

file -L “$SHELL” | grep -q “x86[_-]64″

with this:

file -L “$SHELL” | grep -q “[xX]86[_-]64″

${ANDROID_NDK}/build/core/init.mk: Replace line 229:

ifneq (,$(shell file -L $(SHELL) | grep ‘x86[_-]64′))

with this:

ifneq (,$(shell file -L $(SHELL) | grep ‘[xX]86[_-]64′))

As a note, you should be using the 64-bit NDK if your system supports it, since you will get 30% faster builds. The 64-bit tools utilize host resources better (faster, handle larger programs, etc) and they should function identically to their 32-bit counterparts, i.e. 64-bit toolchains still generate 32-bit binaries for Android.

This issue will be fixed by Google in the next release of the NDK. We will update this post with any new information we receive.

Appcelerator Titanium: Patterns & Best Practices (Book)

The following guest spot is courtesy of Trevor Ward (@thewarpedcoder) and Boydlee Pollentine (@boydleep), the authors of the new “Appcelerator Titanium: Patterns & Best Practices” book. Trevor and Boydlee are both active Titanium community members and Titans contributing across a wide-range of activities, including organizing Titanium conferences, speaking at mobile  conferences, hosting Titanium trainings and helping out on the Q&A to name a few.


It is nice to be asked by Appcelerator to contribute to their blog. Especially when you get the chance to promote a new book.

Over the last few months Boydlee Pollentine and myself (Trevor Ward) have been working on providing a resource we hope will help people using Titanium. On the 23rd February Appcelerator Titanium : Patterns and Best Practices was released via packt publishing.

The book starts by covering some best practices for JavaScript and Titanium, before showing how to implement commonJS and cross platform design methods. The final chapter explains how to implement a non SQL solution using jsonDB.
While writing this post I thought I would see if anybody had reviewed the book, and Jason Kneen said this:

“This book is essential reading for anyone developing with Titanium. If you’re new to Titanium, this book will give you a firm foundation on which to build your apps to ensure code is clearly written, well-structured and application resources are well managed. Even if you consider yourself an experienced developer there are still tips in this book that will improve your code and the performance of your applications. Some great advice on reusability of code and cross-platform development too.”

We hope you like it and it provides a useful benefit to your coding.

The book can be purchased through any Amazon store or directly from the publishers.


Titanium Mobile Tizen now available

Hot on the heels of our preview release several weeks ago, we’re pleased to announce GA support for the new Tizen platform in the Titanium SDK. Tizen is a robust and flexible operating system, based on Linux and HTML 5. Available devices include smartphones, tablets, netbooks, in-vehicle dashboards and smart TVs.

The general availability of Tizen support is included as part of our 3.1.0 release. However, we are promoting it in advance in order to encourage you to begin developing applications for the platform in anticipation of the May opening of the Tizen app store. As such, we’ve tested a particular build of 3.1.0 for Tizen support, and we are linking to that directly from the platform page below. To get started, read more here. There are some important items to watch as part of the release notes in regards to the Tizen tooling on OS X, so please review the aforementioned linked page carefully.

Feedback and contributions are appreciated. You can check out the repository at https://github.com/appcelerator/titanium_mobile_tizen. We welcome your contributions and support of this new addition.

Page 6 of 92« First...45678...203040...Last »