Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Saturday, November 1, 2014

Appcelerator Titanium Android Woes on Mac OSX

I have been having ongoing problems getting Appcelerator to build and install Android Apps again.

The very first time I built an Android App it took me some time to get the configuration right. Now that I have been through system upgrades I seem to have come back to step one again. Like before the official Appcelerator Guide helps me refresh how you get the device itself configured. However, it will not prepare you for the grand cluster of configuration issues you will face getting all the toys to play nicely together.

Problem 

Appcelerator does not recognize your android device.
Even though if you run adb devices you can see it listed.

Solution

I still don't have a solution for this (most people suggest uninstalling everything and starting again, which to my mind constitutes giving up not solving it). I do have a work around though: Build the app without installing it and then use adb to install it independently. This definitely works in the absence of a better solution.

To build

Try the command titanium build,
- or -
Just use the distribute app dialog in Titanium Studio.
You can generate a signed APK easily this way.

To install

Just use the adb command line utility:

   adb install ../Desktop/MyApp.apk

Problem solved,... sort of.


Problem

adb does not even recognize your android device.
This seems to happen randomly, depending on what I had for breakfast.


Solution

I generally find this requires a little fiddling around. This particular combination is currently working for me:
1) Unplug your device.
2) Kill the adb server.
3) Plug your device back in
4) Run adb devices
This seems to kickstart the adb server in such a way that it correctly finds the attached devices.

Problem

Your android App almost builds an APK but red errors flash up at the end. Appcelerator tells you it was built but there is nothing in the build directory. You see a bunch of uninformative python errors codes referring to problems with the file: builder.py, for example:

line 2528, in <module>
[ERROR]     builder.build_and_run(False, avd_id, debugger_host=debugger_host, profiler_host=profiler_host)

For me it turned out that this is all because of the fact that some executables got moved around between distributions of the android SDK.

This problem is outlined in this note from the Appcelerator forums fixed it for me.

Solution

Create symlinks to aapt and dx in /Applications/Android-sdk/platform-tools:

ln -s /Applications/Android-sdk/build-tools/17.0.0/aapt aapt

ln -s /Applications/Android-sdk/build-tools/17.0.0/dx dx


Thursday, August 23, 2012

App Distribution Key File Backup

I have been developing apps using Appcelerator's Titanium Studio for the past year. Unlike some of the other multiple OS distribution methods Appcelerator allows you to generate native controls and widgets across multiple platforms. They have a strong user community and the stability of the apps produced is excellent (contrary to the negative reviews found online).

In my standard backup process I create regular copies of the code base for my apps. However, it has come to my attention that for the sake of security you need to back up more than just your code.

When you distribute apps to the app stores, they need to be signed used using the private keys associated with your development certificates. If these keys are lost then you will be unable to publish updates to your apps.

So if you develop for Android and iOS as I do, here are a couple of links that give you the critical information.

iOS
Read this post on backing up your private key and follow the instructions at the bottom.

Android
For android releases to Google Play, you need to make a back up of the keystore you created with keytool. This is the android guide to application signing. You will have used the keytool command to create a key for your application before distributing, as described in this how-to. You simply make a back-up of the file listed when you run the command
keytool -list -v -keystore /XXXXXXX