Intro

The Fastdev server enables Titanium developers writing Android apps to rapidly test and see the changes they make in code. Instead of re-deploying the app after changes are made, the app requests whatever it needs under Resources from the Fastdev server. In other words, when Fastdev is running and your app requests app.js (or just about anything under Resources), the latest version of app.js on your dev machine gets served up to the app – there is no need for the full build-and-release process.

Currently Fastdev is only supported for the Android Emulator, but it will also be supported for devices in an upcoming release.

Pre-requisites

Getting started with Fastdev

Demo Video / Blog

See the introductory blog and demo video here:
Titanium Mobile Intro Series: Fastdev for Android

Starting the Fastdev server

To put your app in Fastdev mode, you'll first need to run the Fastdev server, and re-deploy your app:

At this point, you should be able to make changes to nearly anything under the Resources directory, and they will be immediately available to your app. Keep in mind that changes aren't actually uploaded to the app, but rather the app will request the changes the next time they're needed. This means that in some cases, i.e. changes in app.js, you will need to restart the application to see the change. A restart here simply means restarting the app itself, not a full rebuild (like in previous versions of the MobileSDK).

You can control whether Fastdev starts by default when you launch your app by adding the following code to the project's tiapp.xml file:

<property name="ti.android.fastdev" type="bool">true</property>
Restarting a Fastdev app

Any one of these methods will cause the app to restart:

  1. "Fast" restart

    $ titanium.py fastdev restart-app
    
  2. Re-run the application: You can just the same command as above:

    $ titanium.py run --platform=android --android=/path/to/android-sdk
    
  3. Manually restart by pressing the emulator's Back button, and clicking on it's icon in the App chooser.

However, keep in mind that you don't always need to restart your app for changes to take effect. For example, if you're using Ti.UI.createWindow with the url attribute set, then any time that window is opened it will reload the JavaScript code in url using Fastdev. Similarly, any time Ti.include is called, Titanium will make a request using Fastdev. Generally, only changes in app.js, and any scripts it might include with Ti.include will require an application restart.

Other Resources

Fastdev is primarily concerned with the files under the app's Resources directory, which means that any changes to the project outside of Resources will require you to manually re-run the application as decribed above. Generally, this means these kinds of changes will require a full rebuild / redeploy:

Fastdev also supports the platform-specific Resources/android directory, which maps directly to Resources, however any special android native images that are changed in Resources/android/images/$CONFIG will require a full rebuild (where $CONFIG is one of low, medium, high, or an Android resource identifier such as res-long-mdpi).

Common Issues or Problems

Running the Fastdev server in the background

When starting Fastdev at the command-line, you may want to put it in the background so you can continue using that command-line instance.
Fastdev can be started in the background a number of ways:

# Run in the background and continue printing in this terminal
$ titanium.py fastdev start &

# Run in the background with log going to nohup.out
$ nohup titanium.py fastdev start

# In Windows, Run with the "start" command
C:\Users\marshall\Code\myApp>start /B titanium.py fastdev start
Changing the Fastdev server's Idle Timeout

The Fastdev server shuts down automatically after being idle (i.e. no new requests by the app) for 30 minutes. You can increase this by passing a custom timeout when starting the Fastdev server:

$ titanium.py fastdev start -t 7200
Android emulator refuses to connect to Fastdev, even though it's running

The Android emulator will sometimes lose it's network configuration (essentially NAT), and fail to connect directly to the host machine. You may notice this when the Fastdev server is running, but the app constantly gives warnings that the connection has been refused or timed out. In this case, the best solution is to completely restart the emulator.

Fastdev Commands

In all cases, the project is taken from the current working directory.

Command

Description

start

Starts the Fastdev server for a project. If the server is already running for this project, this has no effect.

status

Prints the status of the Fastdev server. Warns if the server is not running.

stop

Stops the Fastdev server for a project. If the server is not running, a warning will be issued.

restart-app

Restarts the app currently connected to the Fastdev server. If no app is currently connected, this has no effect.

kill-app

Kills the app currently connected to the Fastdev server. If no app is currently connected, this has no effect.

Full Usage

$ titanium.py fastdev --help
Usage: fastdev.py [command] [options] [app-dir]

Supported Commands:
	start		start the fastdev server
	status		get the status of the fastdev server
	stop		stop the fastdev server
	restart-app	restart the app connected to this fastdev server
	kill-app	kill the app connected to this fastdev server


Options:
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  port to bind the server to [default: first available
                        port]
  -t TIMEOUT, --timeout=TIMEOUT
                        Timeout in seconds before the Fastdev server shuts
                        itself down when it hasn't received a request
                        [default: 1800]
  -l LOCK_FILE, --lock-file=LOCK_FILE
                        Path to the server lock file [default: app-
                        dir/.fastdev.lock]