Time for action – running an app in the emulator
You can run an app from either the run menu or from the navigator window, as shown in the following screenshot:
The buttons from left to right are as follows:
Button |
Text |
---|---|
Collapse All |
Collapse all items in the navigator |
Link |
Highlight in the navigator the current file in the main editor window |
Debug |
Run the app using the debugger |
Run |
Run the app in the emulator or on a connected device (phone or tablet connected to the computer) |
Distribute |
Package the app for release to an Android or iOS app store |
To run the app in the emulator click on the Run button on the navigator window and select your chosen emulator from the list. If you are using a Mac, you can really exploit the power of Titanium by running the app on both Android and iOS at the same time. Otherwise, you will have to content yourself with only running the Android version of the app.
The Android emulator can take a long time to start. It certainly takes much longer than the iOS emulator. On some Android emulator devices, you need to unlock the screen display to allow the app to start.
The Android emulator will generate a lot of console messages (colored white), warnings (yellow), and the occasional error (red). This is normal; however, you may need to keep an eye on the errors to see if anything significant is going wrong.
What just happened?
If you have chosen to run the app on both Android and iOS, you will have two emulators running the Titanium application at the same time, as shown in the following screenshot:
Take a moment to congratulate yourself. By getting to this point you have installed Titanium, configured the emulators, and created your first app. You have come a long way, and have all the tools you need installed and at your disposal. All that remains in this book is to teach you how to make better apps than this.
Did the app fail to run?
Did the following message appear on the console?
"[DEBUG] Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=2 "Simulator session timed out."
It is fairly common to see the timeout error message the first time a new app is run. Titanium has to go through some extra stages running the app for the first time, or the fist time the app is run after a project clean.
Try running it again.
Still didn't run? It's always worth rebuilding the project from a clean build, as this can clear many problems up. First clear down the existing build by clicking on Project | Clean… and then try re-running.