Skip to content


[Titanium] How to detect if an application is running in simulator

Testing for a virtual device can be useful for a variety of features not or poorly working in those, for instance push notifications (last time I tried it just seemed to block the execution) or the camera (as mentioned in this post, on a virtual device you could replace the camera with a “fake” one by loading a picture from the disk).

The Ti.Platform.model variable should contain all you need to determine whether or not you’re running on a real device. On the iOS simulator it will return “Simulator”, on an Android emulator it will return something like “google_sdk”. So a way to test for it would be simply:

if (Ti.Platform.model === 'Simulator'
 || Ti.Platform.model.indexOf('sdk') !== -1 ){
    alert('This is a virtual device');
}

(sorry for the poor indentation, WordPress makes it pretty tough :s)

Sources:
https://developer.appcelerator.com/question/63871/way-to-detect-running-in-simulator
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Platform-property-model

Posted in programming.

Tagged with .


SAS syntax highlighting in Notepad++

I don’t really use SAS much, and when I do most of the time it’s just to read a SAS script and convert some stuff from it into R. So Notepad++ is more than enough to do that (and cheaper, too ;)), but it doesn’t feature SAS syntax highlighting by default. However you can easily add it, all you need (unless you want to implement it yourself), is a user-defined language file. Gladly, some people worked on this and this post at hafniumcity provides such a UserDefineLang.xml file (and just in case it went offline, I mirrored it here).

To use it:
– if you already have a UserDefineLang.xml file, you’ll need to edit it (for instance with Notepad++) so as to add the new “sas” language definition in it, along your already defined languages
– if you don’t already have a UserDefineLang.xml file, you should place the new one either in %appadata%\Notepad++ or right in the Notepad++ folder, if like me you configured Notepad++ in a portable settings (use a local folder instead of the %APPDATA% folder, this is a setting defined upon (re)installation)

Posted in programming.

Tagged with , .


Installing Titanium on Mac OS 10.10 Yosemite

Again, not a detailed step-by-step guide but mostly tips on the most annoying parts.
A brief overview of the setup process though: download the package from Appcelerator, launch it, and drag and drop the Titanium icon to the Applications folder in the window that pops up (that process never ceases to amaze me: why on Earth require such kind of user input ? Apple, eh….)

Now you can already run it as any other application, however you are likely to encounter an error telling you that you need Java 6, or maybe some more cryptic error message instead, like The JVM shared library “/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib” does not contain the JNI_CreateJavaVM symbol. The solution to this is to install Java for OS X 2014-001 (source).

The second issue I had was a fairly unspecific An internal error occurred during: “Computing SDK Info…”. java.lang.NullPointerException. A reported solution was to install Titanium CLI from the command line (sudo npm install titanium -g), however in my case, just running the update process a couple of times (and restarting Titanium in-between) did the trick.

Posted in programming.

Tagged with , .


Publishing a Titanium application to the Apple App Store

Due to a lack of redaction time every time I have to experience with that submission process, this isn’t a full, step-by-step guide but a brief compilation of the issues I ran into (and the solutions that worked for me).

I’ll skip the certificate and provisioning profile part because that’s something “intuitive” enough and if anything else fails you can just revoke the previous ones and create a brand new production signing certificate and a provisioning profile that matches. An important thing to note though is the keychain utility (not very sure how it’s exactly called), which allows you to export your keys, and also view which keys are installed (and whether or not you just have the public key or also the private one, which is of interest here).

Ok, so now you have a signing certificate (with the private key), and the provisioning profile, and you launch the package compilation targeting the App Store in Titanium. Titanium tries to do everything automatically, which includes a few steps of manipulating windows and auto-clicking some buttons. However, doing so requires some specific permissions, and you are likely to encounter, the first time you do it, an error message saying “UI element scripting is not enabled. Check โ€œEnable access for assistive devicesโ€”. I think that error message tries to point you to the ad hoc settings window, however this window was move in Mac OS 10.9 (Mavericks), and Titanium still points to the old one. The new setting is located in System Preferences → Security & Privacy → Privacy → Accessibility. There you can check Titanium to allow it to “control your computer” (if the checkboxes aren’t clickable, unlock the settings by clicking on the lock at the bottom-left of the window) (source).

If you’re on Mavericks that should be enough. However, further changes were made in Mac OS 10.10 Yosemite, and when you run Titanium packaging again, as of Titanium 3.4.0 you should land onto a window listing your real and virtual devices: the compilation was done successfully, but the step to package and submit is left unfinished. The missing steps are however easy enough, provided that you know what has to be done.
First you should open the XCode Provisioning Organizer. For this, simply open XCode (Titanium should already have opened it for you), then in the menu: Window → Organizer (source).
Once in XCode Organizer, you should probably land on the right tab, but if you don’t, pick the “Archive” tab. I didn’t take a screenshot so here is one from someone else. Now click distribute, and make sure to uncheck “Include app symbols for your application to receive symbolicated crash logs from Apple” otherwise you will probably get an error saying “rsync failed” (source).

Well, hopefully that’s it now. This last step send your packaged application to your iTunes account, and now the package is ready to be added to your application submission/update form.

Posted in Apple, programming.

Tagged with , .


Getting started on debugging an Android app on Samsung Galaxy devices

I used that on a Galaxy S3, but probably this works with a lot more Galaxy devices. Also the first step is common to any Android device I think (at least where Android is recent enough).

Step 1: enable developer tools on your Android device:
Go to settings → More → About device (on the Galaxy S3, that’s at the bottom of the System subsection)
Tap 7 times on the build number (on the Galaxy S3, again that’s at the bottom of the section)
You should get a message that developer tools are now unlocked

Step 2: enable debugging:
After the previous step, go back to the menu screen where you previously found “About device”. You should have a new menu item (just above “About device” on a GS3) called “Developer option”.
Go there and enable USB debugging

Step 3: install Samsung USB drivers on your computer:
Grab the Samsung Android USB Driver for Windows there (or you can also use my mirror) and install them. That should work without a restart provided you didn’t have ADB running while performing the installation.

Now you’re ready to plug your GS3 and get compiling ๐Ÿ˜‰

Sources:

Posted in programming.


[Titanium] Solving an early build failure

I believe this error message is quite standard at the end of a failed build in Titanium:
[ERROR] Application Installer abnormal process termination. Process exit value was 1

A probably rarer sight is when this occurs very early in the build, when few to none previous build messages are available to provide any clue on what the heck is happening. I had one of those lately, a failed build after just one single, unhelpful message, with a complete log consisting of just:
Titanium Command-Line Interface, CLI version 3.4.0, Titanium SDK version 3.4.0.GA
Copyright (c) 2012-2014, Appcelerator, Inc. All Rights Reserved.
Please report bugs to http://jira.appcelerator.org/
[INFO] : Found Titanium module id=ti.draggable version=1.0 platform=android deploy-type=test path=D:\PROG\PROGRAMMING\xxxxx\modules\android\ti.draggable\1.0
[ERROR] Application Installer abnormal process termination. Process exit value was 1

So I just searched for any possible solution, and gladly the first suggestion I found was a good one: simply delete the whole “build” folder, so as to recompile a whole new build from scratch (some corrupted temporary build file(s) I guess). Deleting the build folder, however, turned out to be quite a pain: I had permissions issue, Windows telling me I should be an administrator to delete that folder, even though I was one. I ended up booting to Linux just to delete that nasty folder (if you don’t have a dual boot, I guess you just won a live DVD ;)), but it worked, and so did the compilation.

Source, with additional possible fixes (although some of those were given as a solution to much more verbose build logs) is here: http://developer.appcelerator.com/question/142108/error-application-installer-abnormal-process-termination-process-exit-value-was-1

Edit a few hours later: Titanium really has a lot of potential generating such shitty errors. Another common sight is "build\android\build-manifest.json does not exist in Titanium Studio". Same kind of mess, same kind of fix. Note that another option is to use Project → Clean, but for me it didn’t work because that Titanium idiot somehow managed to create a file (I think that was build\android\assets\app.js) that it’s not able to delete itself. Even more options are presented in this stackoverflow post. Good luck, we all need it with those massively stochastic errors :s

Posted in programming.

Tagged with .


[Titanium] Solving no Android SDKs were found under the specified SDK location

It seems that with every Titanium upgrade comes a bunch of big, annoying issues. I just upgraded from Titanium 3.3.0 to 3.4.0, and this time the issue was Titanium wouldn’t see the Android SDK anymore. The proper error message was well hidden, at first all I could see was that Titanium wasn’t able to find my debugging device (and external LG 975) anymore. After upgrading the Android SDK (a few minor upgrades I believe) and messing around in the options, I eventually found a proper error message in Preferences → Studio → Platforms → Android (note that I have absolutely no idea how to reach that Preferences window without using the tool icon next to the OSes under “Deployment Targets” in the tiapp.xml GUI editor): “[Android SDK Home] No Android SDKs were found under the specified SDK location”.

So, Titanium couldn’t see the Android SDK, even though I indicated the proper path (very same as the one used with the previous version). Puzzling, as usual…

I found people mentioning this issue when upgrading to Titanium 3.2 from 3.1. Not really my case, but now I know/suppose that’s a recurring issue.

Then I found someone mentioning I should delete a specific config file, namely C:/Users/[username]/.titanium/config.json. I did, and it worked. As I was curious, I kept a copy of the old version, and then compared it to the new version. The only difference is that the new version removed an item at the end. The old version was:

{
	"user": {
		"locale": "en-us"
	},
	"app": {
		"workspace": ""
	},
	"cli": {
		"colors": true,
		"completion": false,
		"logLevel": "trace",
		"prompt": true,
		"progressBars": true,
		"failOnWrongSDK": false,
		"httpProxyServer": "",
		"rejectUnauthorized": true,
		"width": 100,
		"ignoreDirs": "^(\\.svn|_svn|\\.git|\\.hg|\\.?[Cc][Vv][Ss]|\\.bzr|\\$RECYCLE\\.BIN)$",
		"ignoreFiles": "^(\\.gitignore|\\.npmignore|\\.cvsignore|\\.DS_Store|\\._.*|[Tt]humbs.db|\\.vspscc|\\.vssscc|\\.sublime-project|\\.sublime-workspace|\\.project|\\.tmproj)$"
	},
	"paths": {
		"commands": [],
		"hooks": [],
		"modules": [],
		"plugins": [],
		"sdks": [
			"C:\\Users\\Admin\\AppData\\Roaming\\Titanium"
		],
		"templates": []
	},
	"android": {
		"sdkPath": "D:\\PROG\\PROGRAMMING\\adt-bundle-windows-x86_64\\sdk"
	},
	"sdk": {
		"selected": "3.3.0.GA"
	}
}

and the new version removed

	"sdk": {
		"selected": "3.3.0.GA"
	}

Source is here, and contains a few other things to try, in case this one doesn’t work for you…

Posted in programming.

Tagged with .


Our server exploded

Well, not really, but the result is quite similar. The server crashed early in the night, only this time a reboot didn’t help. There had been hard drive issues for a while, only I really didn’t have time to do yet another migration, and I was hoping RAID 1 would help (one of the drives had issues, but the other worked fine, without a single error in S.M.A.R.T. diagnosis) to remain online long enough until my schedule cleared up.

So, well, a few sites are back up, the others will take longer.

Some interesting lessons were learned, though:
– Murphy’s law has been once again verified
– when a server starts behaving strangely (like, Tor deamon stopping for no reason), trash it
– *particularly when you have diagnosed hard drive issues
– *and when the strange behavior also includes random crashes
– don’t rely on RAID 1 for proper redundancy at EUserv, their RAID controllers seem… well, a bit wacky. Either that, or I’ve been really massively unlucky with them. But their vKVM thing for dealing with non-booting servers is quite neat ๐Ÿ˜‰
– don’t use a trial offer as a secondary DNS just because the quota is about good enough. At BuddyDNS I used to use my 300k monthly queries quota in about 25 days and finish the month without secondary, but after just 7 hours of downtime today that quota was used up. I may have missed a few e-mails :s
– don’t set your DNS serial blindly to the “recommended” format of YYYYMMDDXX without thinking it through first: once you’ve done that, it’s very hard to go back to 1, 2, 3, etc. (this is how I ended up on buddyDNS on the first place, because trying to go back to 1 2 3 broke my previous secondary DNS provider)
– some other lessons were learned, but promptly forgotten before making it into this post. The lesson for this is write down the lessons you learn as soon as you learn them.

Last but not least, very sorry for that downtime folks ๐Ÿ™

Edit: well it turns out that all it took to bring the server back online was to run an fsck from the vKVM… Now smartmontools doesn’t even detect any fault on the “bad” hard drive, and more surprisingly, not a single reallocated sector either. The lesson to trash the server will still apply though (when I have the time), and this notepad stays on the new server anyway ^^

Posted in Uncategorized.


[Titanium] Unable to find Android SDK tools: zipalign

I recently upgraded Titanium, and possibly also my Android SDK (this is getting a bit messy, with the old SDK, used by Titanium, living along with the new SDK brought by the new, beta, Android Studio). And when compiling an app for Android, which I hadn’t done in a long while, I encountered this error:

[ERROR] : Unable to find Android SDK tools: zipalign.
[ERROR] : You have an incomplete or out-of-date installation.
[ERROR] : Verify your Android SDK packages or reinstall the Android SDK by running titanium setup android or manually downloading from http://appcelerator.com/android-sdk.

I opened the Android SDK manager, but no obvious package seemed to be missing. Finally, I found someone suggesting to move around that “zipalign” tool itself. So, I eventually found zipalign.exe in adt-bundle-windows-x86_64\sdk\build-tools\android-4.4W, and copied it into adt-bundle-windows-x86_64\sdk\tools. Success! ๐Ÿ™‚

Also, thanks very much to the guy who posted a close enough answer there: http://developer.appcelerator.com/question/175598. Too bad his answer wasn’t marked as the proper solution, the chosen one is rubbish…

Posted in programming.

Tagged with .


How to back up freenet download list

Freenet has the annoying habit of corrupting its download database on a fairly regular basis, even when you don’t encrypt said database, and even when you run it from a very fast drive (even a RAM disk…). On top of that, it doesn’t provide an obvious feature to back up the download list. And as you probably have noticed, once the database is corrupted you can’t even show the list of downloads. So, what we need is an easy way to back up said list, easy enough to be run proactively on a regular basis without being much trouble.
It turns out there is an easy way, apart from the fact that it’s not shown on the Freenet interface. The list of current downloads can simply be obtained from http://127.0.0.1:8888/downloads/listFetchKeys.txt

Posted in software.