Thursday, February 16, 2012

Porting Android Applications to BlackBerry PlayBook

Every mobile developer's dream is to port their apps to every platform, Android, iPhone, BlackBerry, Windows Phone, etc at least that is my dream. Last year I did the first step by launching my Android app in the Android Market. Since then I have been busy with work and my travels but I got the time to make the next step. I finally ported my Android app to the BlackBerry PlayBook Tablet :) :)

The process to publish your app in the BlackBerry App World is a little bit complicated for sure more complicated than the Android Market.

The first thing you want to do is to make sure you can port your app, sadly not everything is supported; for now you can only port Android apps targeted to Android 2.3.3 API revision 10 a.k.a GingerBread and even if your app is using that specific version, the list of unsupported APIs is long, you can check the complete list here and here.

The easiest way to test if your app is portable, is using the command line tool, just download it execute this:

apk2barVerifier <apk-dir>|<apk-file> [<Android SDK path>]

The tool will tell generate a .sum file and it tell you if you have any errors and one thing for sure is that the tool does not give a lot of information about what is wrong with your application. If it is failing, it will only tell you that it found errors and that is all, sucks, isn't it? The very first time I run it the message i got was this one:

impact-summary: [5]=1; [4]=0; [3]=0; [2]=0; [1]=0;
ChmbrsNotes.apk: [5]=1; [4]=0; [3]=0; [2]=0; [1]=0;
Impact Legend: [5]=Severe; [4]=High /context; [3]=Medium /context; [2]=Medium-low /context; [1]=Minor;

It says I have one severe error but that is all. I did not know where to look, change or remove. I had to go piece by piece in my Manifest file and remove every part and test. It sucks!

Once you solve all your compatibility issues it is time to deploy and debug in the simulator. In order to debug it you can download the plugin for eclipse which also comes with the command line tool integrated it which is handy since you can check your progress every time. The plugin allows you to do a couple of things like packaging, repackaging, debug, even sign your app for the BlackBerry App World.

Before you set up your plugin I recommend getting your keys and also download VMPlayer and the image to load the simulator. Once you request your keys probably will take a couple of hours to get approved so request them with time also you will need the keys to set up the eclipse plugin and the simulator. It is weird they request keys to deploy apps in the simulator but once you are done testing you can sign your app right away. In Android it signs the applications with a debug key and once you are ready to upload it to the Android Market you create your key. So either way you need keys so i guess it is fine.

This video explains pretty much everything until this step.

What this video does not say is that it takes a lot of time to register and get approved as BlackBerry Vendor. It took like 2 days for me to get the approval and they even asked me for a Photo ID scan so I can prove my identity. You can register yourself here and probably you want to do it with time.

Once you are registered you need to sign and submit your application for approval. In order to do that you need fill out more forms, pick an application name ( if it is available) upload bunch of promotional images, icons, a nice description and decide country and carriers availability and of course if you are going to charge for it or not. Mine is free so I do not know what the process is for paid applications probably you will need to set up Paypal or any other way of payment. It took another 2 days to get the approval and once you get it you are allowed to publish your application for sale, the good thing though is that everything is free there is no registration fee or anything like that.

You can get all the information and tools in the BlackBerry Runtime for Android Apps web page. It is still in beta and their documentation could have been better and also the forums did not help at all with my compatibility issue but at least they have all the tools out there. I wish the could support more than Android 2.3.3, at least it is a nice start.

I guess once you see it online and ready to be downloaded you feel like you have accomplished something :)

Chmbrs NotePad in the BlackBerry App World :)

Hope it helps some one, happy coding :)