View
 

Getting Started with PhoneGap-BlackBerry with the Latest Environment

Page history last edited by Karthik Jayapal 1 wk ago

Getting Started with PhoneGap-BlackBerry (Latest Environment)

 

This article explains how to setup the latest BlackBerry development environment. If you have trouble with this article, you may want to setup the legacy environment.

 

The BlackBerry developer environment is an Eclipse Plugin that includes a BlackBerry simulator and tools for application packaging / deployment.

 

Important

 

  • This guide is intended for Windows. It has been tested on Windows XP x86 and x64.
  • OS X partially works, but Eclipse cannot detect installed versions of JDE.
  • Currently, PhoneGap does not run on JDE 5.0.

 


 

Sun JDK

 

  1. Download the latest version of the Java Developer Kit (JDK).
    • At the time of writing this article, the latest version is JDK 6 Update 20.
    • You must install a 32-bit version of the JDK.
    • The BlackBerry Plugin can only recognize a 32-bit JDK and Eclipse IDE. 
  2. Install the JDK.
    • During the installation, you will be asked to install the Java Runtime Environment (JRE) - please do this.

 

Eclipse IDE

 

  1. Download the latest version of the Eclipse IDE for Java Developers (or Eclipse IDE Classic).
    • At the time writing of this article, the latest version is Eclipse 3.5.2 (Galileo).
  2. Install the Eclipse IDE.
    • Install by extracting the ZIP archive to a desired installation directory.
    • e.g. C:\Program Files\Eclipse\Eclipse-3.5.2 
  3. Run the Eclipse IDE for the first time.
    • To ensure there are no problems with the installation.
  4. Close the Eclipse IDE. 

 

BlackBerry Plugin for Eclipse

 

  1. Download the latest BlackBerry Plugin for Eclipse.
    • You will need a BlackBerry Developer Zone account (free).
    • The Plugin's name is misleading. BlackBerry Java Plugin for Eclipse v1.1 means the Plugin version is 1.1 (not Eclipse). 
  2. Install the Plugin to the Eclipse directory.
    • Make sure Eclipse is closed. 
    • The Plugin must be installed into the root of your Eclipse directory.
    • e.g. C:\Program Files\Eclipse\Eclipse-3.5.2\

 

BlackBerry JDE Component Packs

 

The JDE component packs allow you to build your Blackberry application for a specific Blackberry platform. By default, the BlackBerry Plugin includes JDE 5.0.

 

  1. Open the Eclipse IDE
  2. Select Help > Install Software
  3. Click the button Add..
  4. Select the JDE component packs.
    • Select versions 4.7, 4.6.1, and any others that you want. 
  5. Click OK
  6. Select Next > Next > Finish
    • There is a legal agreement on the last window
  7. When the Authentication prompt appears
    • Username & Password is your BlackBerry Developer Zone account.
    • If multiple login prompts appear, then enter your credentials into each.
      • Cancelling any login prompt will cancel the installation. 
  8. Restart Eclipse when prompted.
    • Do it. Restarting Eclipse is important. 

 

Aptana Plugin for Eclipse (Optional)

 

Installing the Eclipse Aptana plugin will enable HTML and JavaScript syntax highlighting.

 

  1. Open the Eclipse IDE
  2. From the menu
    1. Select Help > Install New Software...
  3. Click the Add... button
    1. Name: <Leave Blank>
    2. Locationhttp://download.aptana.org/tools/studio/plugin/install/studio
  4. Check the box next to the Apanta plugin
  5. Click Next until Finish 

 


 

PhoneGap Application Setup

 

Create a BlackBerry Project

 

  1. Open the Eclipse IDE.
  2. Select File > New > Project...
  3. Select BlackBerry Project
  4. Press Next
  5. On the Create a BlackBerry Project screen
    • Project Name: Enter a name for your application
    • Use Project Specific JRE: Select JRE 4.7 or under
      • JRE 5.0 does not currently work with PhoneGap
  6. Press Finish.

 

Import the PhoneGap-BlackBerry Project

  1. Download the PhoneGap-BlackBerry source.
    Click the Download Source button in the top-right.
    Extract the PhoneGap-BlackBerry source. 
  2. e.g. C:\PhoneGap-BlackBerry\
  3. Copy & paste the following directories:
    • C:\PhoneGap-BlackBerry\app\www => C:\<Your Eclipse Project Path>\src\www
    • C:\PhoneGap-BlackBerry\framework\src\com => C:\<Your Eclipse Project Path>\src\com
    • C:\PhoneGap-BlackBerry\framework\src\org => C:\<Your Eclipse Project Path>\src\org
  4. Open the Eclipse IDE
    Right-click on your BlackBerry-PhoneGap project
    Select Refresh 
    You should now see \com, \org and \www packages under the \src tree 

 

Run the PhoneGap-BlackBerry Project in the Simulator

 

  1. Open the Eclipse IDE
  2. Right-click on your PhoneGap-BlackBerry Project
    • Select Run As > BlackBerry Simulator
  3. The simulator will open and run your application.
    • The application can be found in the simulator's Downloads directory.

 

Enable HTTP Connections in the Simulator

Automatic Approach

  1. Open the Eclipse IDE
  2. Right-click on your PhoneGap-BlackBerry Project
    • Select Run As > Run Configurations...
  3. In the right-side panel
    • Select the Simulator tab
    • Select the General tab 
    • Check Launch Mobile Data System Connection Service (MDS-CS) with simulator
  4. Click Apply
  5. Click Close 

 

Manual Approach

  1. Run the MDS-CS batch script for a specific JDE Component Pack
    • e.g. C:\Program Files\Eclipse\Eclipse-3.5.2\plugins\net.rim.ejde.componentpack4.6.1_4.6.1.36\components\MDS\run.bat
  2. If the run.bat window does not remain open 
    • Set your JAVA_HOME environment variable
      • Right-click on My Computer
        • Select Properties
      • Select Advanced tab
      • Click Environment Variables
      • Create a new User Variable
        • Name: JAVA_HOME
        • Value: Your JRE Path (e.g. C:\Program Files (x86)\Java\jre6)
      • Click OK > OK > OK

 

Comments (16)

profile picture

Suneil Berajawala said

at 11:28 am on May 26, 2010

I'm eager to have support for BlackBerry OS 5.0 in PhoneGap as 5.0 gives us a far better browser implementation. Any ETA on when that will happen? Thank you

profile picture

Random said

at 11:52 am on May 26, 2010

I followed these instructions and compiled the test phonegap app for Blackberry App version 5.0.
I called my app test2. I got this error "Error starting test2: Module 'test2' attempts to access a secure API."

It appears one needs to buy Java code signing keys from RIM to get the app to work:
http://na.blackberry.com/eng/developers/javaappdev/codekeys.jsp

profile picture

jo said

at 9:31 pm on Jun 6, 2010

I can't find a BlackBerry project on my Eclipse.

I followed whole thing above manual, but I can't find BlackBerry Project on Eclipse project like this File -> New -> Other -> BlackBerry Project.(I can't find it.)

How could I see a BlackBerry project.
(I'm using Eclipse Galileo)

profile picture

Michael Brooks said

at 10:02 am on Jun 13, 2010

Suneil Berajawala:

The BlackBerry 5.0 SDK has made a lot of changes (for the good) and PhoneGap will need to start a new implementation to take advantage of it. I have started the project and got the basic architecture setup. ( http://github.com/mwbrooks/phonegap-blackberry-widget ). I just need to devote some more time to it. When it is ready, the project will be moved into the official PhoneGap project.
Don't be discouraged by lack of activity on the repo, there is still good progress being made!

Random:

You can correct, you need to purchase some codesigning keys from RIM to deploy to your device.

jo:

The BlackBerry Eclipse Plugin must not be installed correctly. Have you made any progress is getting the BlackBerry project to appear?

profile picture

Jeff Thorn said

at 4:06 am on Jun 22, 2010

I followed the directions above with no problem. I am able to build the app and run it in the simulator. The splash screen displays, but then I get a solid white screen. Nothing else happens. Any ideas? We don't need to sign it to run in the simulator, do we? Any other thoughts?

profile picture

Jeff Thorn said

at 7:16 am on Jun 22, 2010

I think I have discovered the problem I am seeing. The index.html page that is included in C:\PhoneGap-BlackBerry\framework\example references phonegap.js, but this file does not exist anywhere. There are a number of js files in c:\phonegap-blackberry\js, but not a single phonegap.js. I am guessing we will have to copy them to the /src/www directory and reference the ones we need from index.html.

The version I downloaded was 0.9.1. I will try to download the edge to see if this is resolved.

profile picture

Michael Brooks said

at 8:05 am on Jun 22, 2010

Jeff Thorn:

Hey, good to hear that the wiki instructions work for other people's systems! You're right that the phonegap.js is no where to be found. Recently (commit 667951), phonegap.js was removed from the source repo to become more inline with the other major platforms (iPhone / Android). Now, phonegap.js should be generated at build-time (it is just a merge of all JavaScript files in the directory js/ - _phonegap.js must be the first merged file). Unfortunately, no one added instructions on how to do this.

I'll add updating this wiki to my @todo list. The PhoneGap-BlackBerry project comes with an ant script (framework/build.xml) and an ant task called buildjavascript, which generates the phonegap.js. I will need to add another wiki step that involves configuration the Eclipse project to use:
`ant -f C:\PhoneGap-BlackBerry\framework/build.xml buildjavascript`

In the meantime, you have two options to get up and running:

1) Install ant and use it to build phonegap.js (you can also use ant to build the projection and load the simulator - completely bypassing Eclipse). Instructions are found on the PhoneGap-BlackBerry repository README (http://github.com/phonegap/phonegap-blackberry/)

2) I've compiled phonegap.js on my own repository fork. The downfall of using this copy is that it will become out-of-date as new commits are added to the main repo. I updated phonegap.js today, so you should be good for now: http://github.com/mwbrooks/phonegap-blackberry/tree/phonegap_js/framework/example/

profile picture

Hosam Aly said

at 12:26 am on Jul 13, 2010

For those who use Windows but, for some reason or another, don't want to use ant, I've created a batch file that does the concatenation, so you can use it with any upcoming versions. Simply copy the code below into a .bat file in the "js" directory, run it, and take the output "phonegap.js" file.



@echo off

REM delete the output file if it exists
if exist phonegap.js del phonegap.js

REM Rename _phonegap.js so that it comes first in the order of `dir`,
REM then loop over all js files, appending them to phonegap.js,
REM and finally return the renamed file to its original name.
REM If any of these commands fails, show an error message.
(rename _phonegap.js 0_phonegap.js ^
&& (for %%i in (*.js) do type "%%i" >> phonegap.js) ^
&& rename 0_phonegap.js _phonegap.js ^
) || echo Concatenation failed!

profile picture

Michael Brooks said

at 8:43 am on Jul 13, 2010

Nice!

profile picture

Luke said

at 6:24 am on Jul 8, 2010

I can compile, build, and install my application. However, when I go into the downloads folder on the blackberry, I do not see anything. I have set an icon for the app with 32x32. I have given an app name. I have tried using 4.7 and 5.0 JRE on various simulators.

profile picture

Luke said

at 6:42 am on Jul 8, 2010

Found I had to "run as -> blackberry simulator" as the instructions say. I was trying to create a new run configuration and use multiple simulators.

profile picture

Luke said

at 8:47 am on Jul 28, 2010

So can I not use something like

<link rel="stylesheet" type="text/css" href="./assets/themes/earth/theme.css">

inside my index.html file?

I have tried using

<link rel="stylesheet" type="text/css" href="assets/themes/earth/theme.css">
<link rel="stylesheet" type="text/css" href="www/assets/themes/earth/theme.css">

and I perpetually get a JVM Error 104.

Fil Maj sounds like he is on to this one but I dont get his soution.

profile picture

Mike Medwith said

at 1:16 pm on Aug 4, 2010

How is the Black Berry OS 5 going? I don't see any updates and I'd like to use it for a proof of concept at work.

profile picture

Michael Brooks said

at 1:27 pm on Aug 4, 2010

Mike Medwith: I haven't worked on BlackBerry OS 5 past the proof-of-concept. However, I've recently been getting more questions / requests for a more functional (and official) release of PhoneGap-BlackBerry-Widget (or whatever it will be called). So, perhaps it's time to pound out the initial release!

profile picture

Mike Medwith said

at 5:17 am on Aug 5, 2010

Thanks for the update, I'm trying to get your proof of concept working in eclipse. I'm having trouble getting the app to load, I've never used a widget before. I've tried the file --> load option, and also browsing applications and downloads... I cannot seem to find a way to load the widget. Any tips on what to look for?

profile picture

Doug said

at 1:32 pm on Sep 2, 2010

Finally got everything working after a couple hours of scratching my head. Wish I would have read the comments about phonegap.js earlier as this was my biggest issue I could get the interface to load but it wouldn't do anything.

I may add to the steps how to get ant working to build that file to save somebody else sometime in the future. Maybe later today.

Only thing I cant get to work is this. The app builds fine works in the storm 9530 simulator, but when I push it to my phone the app loads and if I click anything it pops the blackberry submenu up.

Probally because I have bb os 5.0 on my strom 9530 :-( and the simulator is running 4.7

You don't have permission to comment on this page.