Monday 27 June 2011

Fixing the "Error getting final archive: Debug certificate expired on xx/xx/xxxx" problem

If you are developing Android applications for a while on the same computer (specifically for more than 365 days) you should be familiar with the "Error getting final archive: Debug certificate expired" error which will stop you from testing your applications.

When the Android SDK is installed, it creates a Debug Key which is used to automatically sign applications when you hit the run button and upload them to the Emulator/Test device. The certificate is only valid for 365 days after which you get the error above.

There are two ways to tackle this issue:
  1. You can either get the Android SDK to recreate a debug key - and repeat this every 1 year.
  2. You can create your own key and set the expiry date yourself.

Friday 24 June 2011

Downloading and Parsing Vendor IDS files to CSV in VB.Net

The following function will parse an ids file and produce an equivalent CSV file. It has been tested with the following two ids files:
  1. The PCI ven/dev list: http://pciids.sourceforge.net/v2.2/pci.ids
  2. The USB ven/dev list: http://www.linux-usb.org/usb.ids
Ids files seem to have two sections; The first section contains the list of hardware and vendor IDs, while the second section has a list of known device classes, subclasses and programming interfaces. This function will only parse the first section. In principle, the only thing that one needs to do to add support for another ids, is to add a line telling the function when to stop parsing (see the idsToCsv() function below, at the beginning of the "Do While objReader.Peek()" loop).

It takes two parameters: "FileInPath" is the location of the OUI file and "FileOutPath" is the path of the CSVyou want to save to. If no file is there, one will be created automatically.

Tuesday 21 June 2011

Checking if an Intent handler or Activity is present

Quite often in Android you need to call a 3rd party Intent or activity.
For example, to scan a barcode using the Barcode Scanner application, or to start the "hidden" Field Test application in HTC phones.

In order to make the life of a user easier, it is a good idea to check if the Intent Receiver/Activity exists before you attempt to invoke it. Some of the reasons being:
  1. If a non-existent intent, you application will force close.
  2. If the intent receiver is not present, you might want to redirect the user to the market to download the necessary application.
  3. Depending on the existence of an intent you might want to make menu options appear/disappear.
This post contains two functions (isIntentAvailable() and isActivityAvailable())which can perform the checking and return a boolean accordingly.