Titanium Mobile: TroubleShooting

The one thing I discovered while using Titanium Mobile, is that trouble shooting is always a pain in the ass. Seriously, most errors don't make any sense, and are not really helping you get to your solution.

I had to figure it out the hard way unfortunately. But, I discovered a lot of solutions which will help you get through most of the problems, considering you didn't really made an error in your code.

So let me get it clear. Your code doesn't build, but you think you did it the right way? Let me help you.

First of all, remove the build. The build can be found here: "Titanium Workspace > Your Project > Build"  and within that directory you'll find an android and/or an iPhone directory. Remove the contents of those directories (don't remove the directories themselves or you might get errors). Usually this method can be used when Titanium says it cannot find a module, and this error usually occurs when you did a build for a device (not emulator). When building for a device, Titanium strips away all unnecessary modules. So when you are using a module you haven't used before it will crash.

Secondly, if that didn't solve the problem, make sure your includes are working correctly. By default titanium should use the resources directory if you include like this:

1
Ti.include('/myfile.js');

But mainly on android these kinds of includes could give errors. The best way to fix this is to use the resources path location. Which would make this line:

1
Ti.include(Ti.Filesystem.resourcesDirectory+'myfile.js');

Note that I'm using Ti instead of Titanium. Ti is a synonym of Titanium and thus can be used like Titanium.

Next up, the error "File not found" in the debugging console in Titanium Studio. This error isn't really an issue of file not found, but it is an issue that there is an error in that file. Usually this is just a regular JavaScript error.

Should these fixes not fix your issue, let me know!

Titanium Appcelerator – Cross Platform App development

For some time now I have been working with the Titanium Platform. This Platform makes it possible to develop apps for Android and iOS all at once. And it actually works pretty good! Now ofcourse, there is a catch. There usually always is. Working cross platform gives you certain limitations. For example, iOS has different possibilities than Android has. Therefore you still would have to do the graphical part per platform, but luckily all the back-end stuff does not need to be developed twice.

The Titanium Platform is actually a JavaScript API. You develop the Apps once in JavaScript, and titanium compiles it for you to Java (for Android) and Objective-C (for iOS). It even is possible to create Apps for BlackBerry, but support for BlackBerry is very small, and is still only available in early beta. Therefore I highly recommend not to use this yet, and stick to Android and iOS for now.

A small example to create an App with just a blank window, which works on both iOS and Android:

1
2
3
4
5
6
7
8
9
10
11
12
var myApp = [];
var myApp.UI = [];
myApp.UI.createAppWindow = function(){
var mainWindow = Ti.UI.createWindow({
backgroundColor: '#FFFFFF'
});
return mainWindow;
}
var window = myApp.UI.createAppWindow();
window.open();

Some problems I encountered while I started with this platform are not to be forgotten. The community is about 1.5 million (as Titanium claims) but I have my doubts about that. There is a Q&A on the website of Titanium, but the real interesting questions on it still are not answered, sometimes even after over 6 months. But over time I found some interesting websites on which you can actually get some information, which might be useful for any of you. Found any more documentation, or nice tutorials? Let me know!