James Wood from Waterloo is working on Blackberry Cordova plugins on Linux and provides this reference for future developers who are trying to do the same.
As of this writing, Linux is not supported by Blackberry for development, which means if you are reading this, that you have chosen to walk the difficult path. The good news is that you won’t be alone, and hopefully this guide will help get you started. The bad news is that a similar guide was written about four months before this one that was already so far out of date by the time I began working the BB10 Cordova, that it was of no use whatsoever. As a consequence, I fear that portions of this guide may also be obsolete by the time you need it. If so, let’s hope that this is because Blackberry has decided to fully support Linux, and a guide like this is no longer needed at all.
Let’s get down to business then.
Before we begin, this guide makes some assumptions about you, the reader:
- You have some idea of what an extension is and does, and moreover, why you want to write one.
- You have a github account, and you have already forked the WebWorks-Community-APIs repository.
- I am using Ubuntu 12.10, and you are (obviously) using some version of linux. Where things might differ between us, you can handle yourself.
- You are working on a machine for which you have administrative rights.
- You have a BB10 device with which to work. I am using the Dev Alpha C model myself.
- Your device has the latest OS installed.
- You can get that here: https://developer.blackberry.com/devzone/blackberry10devalpha/devalpha_update.htm
- Note however that updating the device OS via the autoloader is only possible through a windows machine (at this time)
- You have a Blackberry ID set up already. If you don’t, you can do so from your device directly, although you’ll need an internet connection.
Step 1: Momentics Installation
- Download and install Momentics SDK from
<https://developer.blackberry.com/native/downloads/> 2. Go to the directory where you saved the binary, chmod it to be executable, and run it (as yourself, not as root) 3. I recommend you use all the default settings, unless you have a good reason not to. 4. Allow Momentics to run after the installation is complete. If you don’t, you can always start it from the terminal: ~/bbndk/qde (assuming defaults) 5. On startup, it will attempt to find your device. Let if fail, and see Step 2. If you don’t have one, you can ignore this and always deal with it later.
Step 2: Device Setup
- Turn on your device, and go to Settings->Storage and Access
- Set the USB connection to “Connect to Mac” (see image below)
- Go back to Settings->Security and Privacy
- Scroll all the way to the bottom and select Development Mode
- Turn on development mode (see image below)
- This requires the device password, which I suggest setting to something very simple while you work
- Note that development mode automatically turns off when the device restarts, or after 2-3 days
- Connect the device via USB cable, and on Momentics click “Try Again”
- Enter the device password when prompted
- Install the recommended API level, and go get a coffee (this takes a while)
- If prompted about installing debug stuff, do so, but then do not click restart until it completes (see image below)
- Click restart, but don’t expect it to actually open again on it’s own.
Step 3: More Momentics Setup
- Open Momentics: ~/bbndk/qde
- Go to the menu: Window->Preferences
- Choose Blackberry->Signing from the panel on the left
- Enter your Blackberry ID password and click “Get Token” which will make you actually sign in with your Blackberry ID
- Once successful, click “Create Certificate”. You should no longer see a warning at the top of the page.
- Exit Momentics.
Step 4: Install Node.js
- If you aleady have this, then go to step 5, otherwise enter the following commands from the terminal:
- sudo apt-get install python-software-properties python g++ make
- sudo add-apt-repository ppa:chris-lea/node.js
- sudo apt-get update
- sudo apt-get install nodejs
Step 5: Install Cordova
- sudo npm install -g cordova
- You may need to add /usr/local/share/npm to your $PATH, but I had no issues without doing this.
Step 6: Clone the WebWorks-Community-APIs repo locally
- Make a directory where you want to put it. I made ~/UCOSP since I was doing this for the UCOSP.
- cd ~/UCSOP
- git clone firstname.lastname@example.org:your-git-username/WebWorks-Community-APIs.git
- where your-git-username is your username for github
- Permission Denied? You need to add an RSA key to github. Follow this helpful guide: https://help.github.com/articles/generating-ssh-keys
Step 7: Environment Variables
- cd ~/bbndk
- Notice the file “bbndk*.sh” (see image below). I found that actually running the script did not do as intended, but simply sourcing it was sufficient:
- source bbndk*.sh
- You must do this every time you open a terminal to work, so you might as well add line 4 to you .bash_profile or similar file.
Step 8: Running the Template Sample App
- cd ~/UCOSP/W*/BB10-*/T*
- cordova create sample2
- copy the www folder in /sample to /sample2, and overwrite anything there
- cd sample2
- cordova platform add blackberry10
- This is most likely fail. If not, go buy a lotto ticket.
- The easiest solution is to change ownership of ~/tmp to yourself instead of root, then try again.
- If you find an alternative solution, please document it, and let us know.
- cordova plugin add ../plugin
- cordova run sample2
- Your device will eventually start and app called “Cordova3”
- Click “OK” on the Web Inspector popup
- Scroll down to see the test output from the app
- Congratulations, the hard part is over!