Home Development for Android Porting Android apps to BlackBerry 10

Porting Android apps to BlackBerry 10

by admin

On January 30, Research In Motion introduced smartphones on the new BlackBerry 10 OS. The number of applications in the BlackBerry App World is still significantly less than in Google Play or the App Store, for example. It is possible to occupy the niche by releasing a version of your wonderful application for this OS. All the more so because it doesn’t require a lot of work.
So, as is becoming clear from the information for developers , there are several ways to create apps for BlackBerry 10:

  • C/C++ native applications;
  • HTML5 web applications;
  • Adobe AIR and ActionScript;
  • Android API 2.3.3 runtime;
  • Java BlackBerry runtime.

There are also several ways to turn an Android app into a BlackBerry version: using re-packaging tools, to repackage an existing apk, or using the Android app source code itself for a more thoughtful and thorough porting and then building it for BlackBerry using the BlackBerry Native SDK. Let’s consider the first option as the fastest and easiest.
Porting Android apps to BlackBerry 10

Porting

The first thing to do is to install Command-line tools Of course, you can do with an online tool, but it’s not very convenient to click every time in your browser. You can save yourself the trouble by writing a couple of bat-files using tools from the aforementioned Command-line tools. By the way, besides using console utilities or online tools, you can also use the corresponding plugin for Eclipse.
Assemble the apk file and run it through the verifier, which will tell us what’s wrong with the app. Run :
apk2barVerifier<input.apk>
The output of the utility will look something like this :

D:projectstcsmb_client_androidoutartifacts> apk2barVerifier mib_release_signed.apk
D:projectstcsmb_client_androidoutartifacts> set LIB=C:softblackberryCommandLineTools_1.5blackberry.tools.SDKbin\..lib
D:projectstcsmb_client_androidoutartifacts> java -Xmx512M -cp "C:softblackberryCommandLineTools_1.5blackberry.tools.SDKbin\..libBARPackager.jar;C:softblackberryComma
ndLineTools_1.5blackberry.tools.SDKbin\..libApk2Bar.jar" net.rim.tools.apk2bar.Apk2BarVerifier mib_release_signed.apk
Apk2Bar /Verifier version 1.5.0
Research In Motion Ltd ? 2012 All rights reserved.
[mib_release_signed.apk]:(res/drawable-hdpi/logo_launcher.png) found an alternate icon with better size:impact=1
[mib_release_signed.apk]:(AndroidManifest.xml) uses-permission: CONTROL_LOCATION_UPDATES:impact=1
[mib_release_signed.apk]:(AndroidManifest.xml) native-code: armeabi:impact=5
[mib_release_signed.apk]:Summary:[5]=1;[4]=0;[3]=0; [2]=0; [1]=2;
Summary: [5]=1; [4]=0; [3]=0; [2]=0; [1]=2 ;
Impact Legend: [5]=Severe; [4]=High /context; [3]=Medium /context; [2]=Medium-low /context; [1]=Minor;

The verifier divides the problems by priority groups, there are 5 of them in total. If there are any complaints belonging to priority group 2 and above, then the application is considered incompatible and needs to be reworked. In our case Google Maps and some native libraries, Bump in particular, turned out to be "incompatible". It was decided to remove these libraries from the BlackBerry version of the application. After that, we launch the utility again.

D:projectstcsmb_client_androidoutartifacts> java -Xmx512M -cp "C:softblackberryCommandLineTools_1.5blackberry.tools.SDKbin\..libBARPackager.jar;C:softblackberryComma
ndLineTools_1.5blackberry.tools.SDKbin\..libApk2Bar.jar" net.rim.tools.apk2bar.Apk2BarVerifier mib_release_signed.apk
Apk2Bar /Verifier version 1.5.0
Research In Motion Ltd ? 2012 All rights reserved.
[mib_release_signed.apk]:(res/drawable-hdpi/logo_launcher.png) found an alternate icon with better size:impact=1
[mib_release_signed.apk]:(AndroidManifest.xml) uses-permission: CONTROL_LOCATION_UPDATES:impact=1
[mib_release_signed.apk]:Summary: [5]=0; [4]=0; [3]=0; [2]=0; [1]=2;
Summary: [5]=0; [4]=0; [3]=0; [2]=0; [1]=2 ;
Impact Legend: [5]=Severe; [4]=High /context; [3]=Medium /context; [2]=Medium-low /context; [1]=Minor;

This time there are only two minor problems left that can be ignored for now.

Design refinement

After the steps described above, we had to make changes to the application design: remove items from the menu, sections from the "Payments", adapt banners to the screen size. The main changes touched the main page. Unfortunately, the graphics of the ported application do not behave as predictably as described in guidebooks The size of the elements sometimes had to be adjusted literally "by feel". Some of the sections were put in the context menu. But, in general, with the new main screen and the rest of the screens in the old design, the application looks no worse than the Android version.
Porting Android apps to BlackBerry 10
Porting Android apps to BlackBerry 10

Signing and testing

In order to sign an application we need certificates. We go to and leave an application to get them. Usually the entire receiving procedure takes about two hours, so you’ll have to wait a bit. If everything is done correctly, you will receive two files like client-RDK-123456.csj and client-PBDT-123456.csj RDK file is used to sign the application, PBDT is used to create a debug token.
The next step is to install and register the keys in the system :
blackberry-signer -csksksetup -cskpass <create_a_password>
blackberry-signer -register -csjpin -storepass <RDK_CSJFile> <PBDT_CSJFile>
If you have done everything correctly here, you'll get two more emails confirming that the keys are registered. Next we create a debug certificate, which is necessary if we are going to install the application on the device. If you have an emulator, you can do without it.
blackberry-keytool -genkeypair -keystore <output_file.p12> -storepass <create_a_password> -dname "cn=<company_name> " -alias author

Here I had to spend some time on a trivial error. Note the parameter -alias author author should be left like this, you don’t need to replace it with anything!
Create a debug-token to install on the device :
blackberry-debugtokenrequest -cskpass <csk_password> -keystore <developer_certificate> -storepass <keystore_password> -deviceId0x<PIN_tablet> <debug_token_bar_file>
Your parameter value -deviceId can be found either in the phone settings or in the BlackBerry Device Manager tray.
Turn on developer mode on the device (Settings -> Security -> Development Mode -> Use Development Mode to "On") and register a token to the device :
blackberry-deploy -installDebugToken <debug_token> -device <IP_address> -password <device_password>
We repack our application and sign it with debug-token, using the -d parameter to specify the path to the *.p12 file we created above. Again, if you have an emulator, you don’t need to sign the application and don’t have to use the -d parameter:
apk2bar<Android_app_or_folder> [-d [<debug_token> ]]
That’s it, the application is ready and signed. Installing :
blackberry-deploy -installApp -password <device_password> -device <IP_address> -package <your_app.bar>
Now you can run the application, walk around the screens and check the functionality. At this point, we identified another problem that was not pointed out by apk2barVerifier in the first step. Intents that call other apps (calls, QR- and bar-code scanner, etc.) do not work in BlackBerry. So fix the corresponding functionality and go back to the step with repackaging the apk.
To publish the application in App World, it needs to be signed with a product key. To do this, after packing the bar file ( apk2bar without the -d parameter) you have to execute
blackberry-signer -storepass <store_pass> <your_app.bar>
That’s it, the app is tested and ready to be published to App World. Yes! The created certificates and keys need to back up or if you lose them, you will not be able to sign and upload new versions of the application. To do this in Windows 7, you need to copy 3 files from %HOMEPATH%AppDataLocalResearch In Motion and save them securely

Conclusions

Positive :

  • Ability to quickly get a working version of the application for the new OS with minimal effort.

Minuses :

  • Limited functionality compared to the original Android app (cut out maps, libraries, and calls to other apps);
  • runtime speed (this may be an issue due to the power of the test device, but when compared to the speed of the Android device, the app is slower);
  • alien to the BlackBerry UI and, as a consequence, a negative user experience (the app and especially the navigation in it look worse compared to the native BlackBerry apps).

You may also like