Getting Started with PhoneGap-BlackBerry (Targeting BlackBerry OS 4.6+ Devices ONLY)
This article explains how to setup the BlackBerry development environment for PhoneGap applications targeted at devices running BlackBerry OS 4.6+ ONLY.
This information will not help you develop PhoneGap applications targeted for BlackBerry OS 5+. For instructions on how to do that, see link.
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-blackberry can NOT be used to target devices running BlackBerry OS 5.0 and higher. For instructions on getting started with PhoneGap on devices running BlackBerry OS 5.0 and higher, see the BlackBerry WebWorks guide.
Sun JDK
- 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.
- Install the JDK.
- During the installation, you will be asked to install the Java Runtime Environment (JRE) - please do this.
Eclipse IDE
- 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).
- Users have reported that Eclipse 3.6 (Helios) works fine.
- Install the Eclipse IDE.
- Run the Eclipse IDE for the first time.
- To ensure there are no problems with the installation.
- Close the Eclipse IDE.
BlackBerry Plugin for Eclipse
- 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).
- Install the Plugin to the Eclipse directory.
- Make sure Eclipse is closed.
- The Plugin must be installed into the root of your Eclipse directory.
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.
- Open the Eclipse IDE
- Select Help > Install Software
- Click the button Add..
- Select the JDE component packs.
- Select versions 4.7, 4.6.1, and any others that you want.
- Click OK
- Select Next > Next > Finish
- There is a legal agreement on the last window
- 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.
- 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.
- Open the Eclipse IDE
- From the menu
- Select Help > Install New Software...
- Click the Add... button
- Name: <Leave Blank>
- Location: http://download.aptana.org/tools/studio/plugin/install/studio
- Check the box next to the Apanta plugin
- Click Next until Finish
Apache ANT
- Download ANT
- Extract to a desired installation directory, e.g. C:\apache-ant
- Set ANT_HOME
- Open System Properties -> Advanced -> Environment Variables
- Create a new system variable
- Variable name: ANT_HOME
- Variable value: C:\apache-ant
- Add ANT_HOME to PATH
- Open System Properties -> Advanced -> Environment Variables
- Under system variables, edit PATH
- Add
;%ANT_HOME%\bin to the end of the PATH value.
- e.g. %SystemRoot%\system32;%SystemRoot%;%JAVA_HOME%\bin;%ANT_HOME%\bin
- Verify that ANT is installed
-
Open your command-line tool (cmd.exe or cygwin.exe)
$ ant -v
Apache Ant version 1.8.1 compiled on April 30 2010
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed
PhoneGap Application Setup
Create a BlackBerry Project
- Open the Eclipse IDE.
- Select File > New > Project...
- Select BlackBerry Project
- Press Next
- 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
- Press Finish.
Import the PhoneGap-BlackBerry Project
- Download the PhoneGap-BlackBerry source.
Click the Download Source button in the top-right.
Extract the PhoneGap-BlackBerry source.
-
e.g. C:\PhoneGap-BlackBerry\
- 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
- Build the phonegap.js
-
CD C:\PhoneGap-BlackBerry\BlackBerry\4.x\framework
- Edit common.properties: Edit the
jde.home to point to your Eclipse JDE Component Pack. You must double escape each backslash.
-
Edit project.properties
-
Copy the Blackberry Ant tools and Ant-Contrib JAR files that are in the \util directory of the latest zip file from PhoneGap to => ANT_HOME/lib before building.
-
CD (back to where build.xml is) C:\PhoneGap-BlackBerry\BlackBerry\4.x\
-
ant build-javascript
-
Copy generated phonegap.js to => C:\<Your Eclipse Project Path>\src\www
- 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
- Open the Eclipse IDE
- Right-click on your PhoneGap-BlackBerry Project
- Select Run As > BlackBerry Simulator
- 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
- Open the Eclipse IDE
- Right-click on your PhoneGap-BlackBerry Project
- Select Run As > Run Configurations...
- In the right-side panel
- Select the Simulator tab
- Select the General tab
- Check Launch Mobile Data System Connection Service (MDS-CS) with simulator
- Click Apply
- Click Close
Manual Approach
- Run the MDS-CS batch script for a specific JDE Component Pack
- If the run.bat window does not remain open
- Set your JAVA_HOME environment variable
- Right-click on My Computer
- 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)