BlackBerry Development - Part I

Published on May 10, 2008

Part I of this BlackBerry development guide introduces BlackBerry and attempts to mitigate the getting-started-hurdle. I will convince you why BlackBerry is a great platform - putting up a good fight to nasty Symbian and Windows Mobile. I will highlight issues such as SDK versions, code signing, best IDE, how to set up, online resources, etc..

Why BlackBerry?

All is well explained in BlackBerry FAQ.. My simple reasons are:

  • The trackball is fantastic. The first second I touch it, I know it beats pressing HARD 5-directional buttons on normal mobile device.
  • BlackBerry is not only for business, it is also suitable for individuals, kids or hackers. Why? Its software platform is powerful for many uses.
  • Its battery life is really better.
  • People complain on its phone design, which I agree is not that stylish. But look at this, the future is bright.

Technically, why BlackBerry?

Development on BlackBerry is faster and easier than regular J2ME. Its GUI architecture is much shorter and easier to write. It is native, powerful and has less issues working across the devices it supports. What needs to be done horribly in Symbian can be done much less painfully on BlackBerry!

Code Signing is a breeze in the park, and at a fixed one-time $20! It is easy to apply, easy to sign, and has no different API capabilities grouping or required test house criteria. Symbian is nothing near in this aspect!

Coupled with BlackBerry Mobile Data System (MDS), BlackBerry provides a Push Technology from the server to the mobile, hence more outstanding applications. This simply stands out from Symbian or Windows Mobile!

Java ME - Development language

There are 2 ‘Java ME’ on BlackBerry, and they are different:

  • Regular Java ME - Use regular MIDlets which runs on majority of other brands of phones. The applications are known as MIDlets.
  • BlackBerry Java ME - This is BlackBerry’s extended set of Java ME, which provides much more native features. Note that when this platform is chosen, the regular Java ME concept has to be ‘forgotten’. BlackBerry Java ME has different UI components and different architecture, which in my opinion is even better. The applications are known as BlackBerry Applications.

Development IDEs

There are 3 main IDEs to choose from:

  1. BlackBerry JDE - This is one of the ‘old-styled’ IDE available created by BlackBerry. Not recommended for the professionals..
  2. Eclipse Plugin (Beta)
  3. Netbeans

Personally, I feel more comfortable with Netbeans than Eclipse. But to use for BlackBerry development, it requires a bit of simple configuration. I read from a few sources before configuring things to work perfectly.

Official Netbeans instructions can be found here. It is good but you should not use its build.xml, as it will not copy the .alx, .csl and .cso correctly.

Jonathan Fisher has good instructions here and he has a correct build.xml. But a neater build.xml can be found in another similar guide by Jroller.

Possible pitfalls:

  • You will need to change and add your UiApplication class to Properties > Application Descriptor > MIDlets. The warnings can be ignored.
  • You will need to remove -midlet in build.xml to build a native BlackBerry app
  • To have the alx/cod files compiled in dist, add this to post-jar target in build.xml:
<copy file="${name}.alx" todir="${dist.dir}"/>
<copy file="${platform.home}/simulator/${name}.cod" todir="${dist.dir}"/>

OS Version

Unlike regular Java ME that has MIDP 1.0, 2.0 and etc, BlackBerry Java ME goes by its OS version eg. 4.1, 4.2, etc.. In new versions, there are additional APIs. Methods will be documented which version they are supported since. When an application is built, it depends on the highest version of the methods used.

In other words, you can use version 4.3 SDK and build a 4.1 application provided that you don’t use post 4.1 APIs.

Code Signing

Code signing is a one time $20 USD (previously $100 ?). This means apply for the key once, and you can sign for unlimited applications (to be exact it is 2,147,483,647 signings)! Symbian is nothing near BlackBerry in this aspect!

Possible pitfalls:

  • RIM will email you back with 3 .csi that you need to follow as per the instructions in the email. They will send THREE emails, and all 3 will look so identical that you might think RIM somehow resend 3 times. But it is not… If you install only for 1 of the email, then during signing, you will see a “Not registered” status from the SignatureTool.jar. Just install for the rest of the 2 emails and things will work. RIM should just send an email with 3 attachments!
  • If you need to reinstall the JDK, copy in /bin 3 files - sigtool.csk, sigtool.db and sigtool.set - to the new bin.

Ways to install an application

There are 3 ways to install an application to the phone:

  1. Desktop Manager - install with ALX and COD files
  2. Over-the-air (OTA) - Put the JAD and COD files on the web server and install via JAD file (which points to the COD file)
  3. Javaloader - This is a developer tool to quickly load standalone COD file

OTA Deployment

For OTA installation, place the JAD and COD files on the web server. But note that if the COD file is too large (more than 70 KB), there will be an error downloading - a 907 Invalid Cod error will be shown. To rectify, do the following:

  1. Use Winzip/Winrar to unzip the COD. You should see more than 1 COD file. If you cannot unzip successfully, then the COD file is small enough and there is no problem.
  2. Extract all the files eg. if it breaks up to 2 files: MyApp.cod and MyApp-1.cod
  3. Modify the MyApp.jad with the correct attributes. Eg.
RIM-COD-URL: MyApp.cod
<file size="">RIM-COD-URL-1: MyApp-1.cod
RIM-COD-Size-1: XXX<file size="">

Where XXX are the size of the corresponding COD file.

Put the extracted CODs and modified JAD on the web server and things will work!

BlackBerry in Singapore

BlackBerry is not hot in Singapore. It is strictly used by business users, as they required the push technology, or their company issued them so that they can be contacted 24 hours a day. The BlackBerry data plan is also too expensive. At least $31 for a limited data plan! And $60+ for unlimited!

Online resources