Sunday, August 08, 2010

Blackberry Development Knowledge Dump

While I'm not the sharpest knife in the drawer, I'm far from the dullest. Recognizing my middle of the road capacity for thought, I'm assuming a portion of Internet readers will experience some of the same frustration with Blackberry development that I have experienced. Most notably, what information is current? So, here's a quick dump of some basic Blackberry nuggets of wisdom.

Should you use Eclipse or the Blackberry Java Development Environment (JDE)?

While some may argue that you shouldn't use either (yes, Blackberry development is possible on NetBeans, IdeaJ, etc.), I think most new projects are being done in Eclipse with the Blackberry JDE plug-in.

What version of the JDE should I use?

Notice how I just said not to use the JDE but then referenced the JDE? Get used to it...Blackberry loves ambiguous crap.

Anyway, it appears as though 4.2.1 is recommended for traditional devices, and 4.7 is recommended for the newer touch-screen devices.

How do I build separate cod files for each target platform?

What? You haven't heard of a cod file? Tough...this is Blackberry development. There will be no hand-holding....nor straightforward and complete documentation.

I'm guessing you ditch Eclipse and the JDE for the command line, but who knows. I don't have that kind of time on my hands. Rumor has it this may be easier in other IDE's, but I'm fairly sure there are some Blackberry Ant tools out there waiting for you.

What is a cod file?

Oh, glad you asked. It's your Blackberry application executable. It's analogous to a zip file with other zip and/or jar files inside it, but platforms work better if they ignore simple, established standards?

What are code signing keys?

They're a security measure implemented by Blackberry so evil developers don't do bad things like get the display width and height. Seriously, I'm sure there's some logical reason. Turning off the backlight 255 seconds at a time would definitely run down a battery. Code signing keys to the rescue.

Also, they're a great way to receive a lot of pointless e-mail and require an Internet connection for you to get your work done.

What are the various device resolutions?

Who really knows for certain? The most common are 320x240, 480x360, and 360x480, but you also have 240x260 and 240x320. Good luck writing a useful interface to support all of those devices.

What is compatibility mode?

It's Blackberry's sad attempt at backward compatibility on their touch-screen devices. Apps built for the traditional 320x240 screen will run inside a blue border with a virtual keyboard. What's really fun is you can get your app stuck in this mode even when you're trying to write a touch screen app. The best way I've found to get out of it is to install a new Simulator. What? You accidentally got into compatibility mode on your development device? Well...good luck with that. I'm sure there's a toggle switch somewhere.

What's all this preprocessor stuff?

It's a C/C++ developer's wet dream of how Java development should be. Don't get me wrong...I like a good precompiler macro just like the next guy, but when you have to comment it out to make it work? No, that's just stupid.

Nevertheless, if you want to support multiple builds from one source tree, you will probably need to use precompiler macros. Every file has to have a //#preprocess directive, and you can then use //#ifdef, etc. Of course, the fun part is that Eclipse doesn't recognize the directives and treats them as warnings and ignores that they exist.

My app was running fine a minute ago and now won't do anything now...what gives?

Blackberry has some arbitrary size limit on cod files. If you hit that limit, it's game over. Do not pass go. Do not receive an error message. Do not receive a warning. Experience silent, pointless failures and go directly to jail.