Packaging and deploying apps

You can use the IDE or the command line tools provided with the BlackBerry 10 Native SDK to package and deploy your app.

When you package an app, you create a .bar file. The .bar file is built using information from the BAR application descriptor file and the compiled binaries from the project or code base. You can run your app after you deploy the .bar file to a device or simulator.

Package and deploy using the IDE

After your environment is set up and your device or simulator is set up as a target in the IDE, you can package and deploy your app using the IDE.

Before you can package and deploy your app using the IDE, there are a few things you need to do:
  • Create a BlackBerry ID token and get debug tokens
  • Set Development Mode on your device to On
  • Connect your device to your computer or start your simulator
  • Run the BlackBerry Deployment Setup Wizard
For details, see Set up your environment.

To package and deploy your app:

  1. In the Project Explorer view, expand your project and double-click the bar-descriptor.xml file.
  2. To set the author information for the app, when the file opens in the editor, click Set from Debug Token. If a debug token cannot be found, you need to create a new one.
  3. Right-click your project and select Build Configurations > Set Active. From the list, select Device-Debug if you are going to run the app on a device, or Simulator-Debug if you plan to test on the simulator.
  4. Right-click your project and click Build Project.
  5. Right-click your project again and click Run As > BlackBerry C/C++ Application.

During the deployment process, you may see the message "SDK and Device Mismatch". You can choose to click Continue to run your app. Before you do final testing, get the SDK version that matches your device. Then, you can recompile and rebuild your app. To find the SDK version that matches your device, click Find Matching SDK in the dialog box.

You must update your device to the most recent version of the OS, or to an OS version that matches your customer's environment.

For more build options, see Debug your app and Profiling an application.

Package and deploy using the command line

You can package and deploy your app outside of the IDE by using command line tools.

Before you can package and deploy your app using the command line, there are a few things you need to do:
  • Determine the location of your APPDATA environment variable. In Windows, you can enter echo %APPDATA% at a command prompt. The location should be similar to C:\Users\<username>\AppData\Local\Research In Motion.
  • Create a BlackBerry ID token
  • Set Development Mode on your device to On
  • Connect your device to your computer or start your simulator
  • Run the BlackBerry Deployment Setup Wizard
For details, see Set up your environment.

If you connect to the Internet through a proxy server, you'll need to specify additional command line options to contact the RIM Signing Authority. For more information about using a proxy server in the command line, see Use a proxy server from the command-line.

There are several command line tools you'll need to prepare your device for development, create and upload a debug token, and then package and deploy your app:
blackberry-debugtokenrequest
Creates debug tokens on your computer.
blackberry-deploy
Deploys applications (.bar files) to a device. Use this command to deploy a debug token as a .bar file.
blackberry-nativepackager
Packages your compiled binaries for your app as a .bar file.
blackberry-signer
Digitally signs your app, which is necessary before you publish and distribute your app. You can also use this command to authenticate your BlackBerry ID token.

You can find these tools in the usr/bin subfolder where you installed the BlackBerry 10 Native SDK. To make it easier to run the tools, add the path to the usr/bin subfolder where you installed the Native SDK to the PATH environment variable for your operating system.

For more information about command line tools, run the tool from the command line with no options.

Register your BlackBerry ID token from the command line

You need to register with the RIM Signing Authority using the BlackBerry ID token for app signing by using the blackberry-signer tool. You only need to register your signing token once.

To register your BlackBerry ID token:
  1. Run the following blackberry-signer tool where:
    • <password> is a password that you specify for the keystore.
    • <bbidtoken.csk> is the pathname to the app signing .csk file you downloaded when you created your BlackBerry ID token.
blackberry-signer -storepass <password>
               <bbidtoken.csk>
After you register using the blackberry-signer tool, the following files are created in the AppData folder:
  • author.p12
  • barsigner.csk
  • barsigner.db

The message "Successfully registered with the server" is displayed and an email is sent to you. It is a good idea to back up your signing token. For more information, see Back up and restore your code signing keys.

Create and upload a debug token from the command line

If you are working with a device and not the simulator, you need to add a debug token to your device to run an unsigned app.

To create and upload a debug token:

  1. Change directory to where you installed the IDE.
  2. Run the following blackberry-debugtokenrequest tool where:
    • <csk_password> is the password for the keystore that you used when you registered.
    • <pathname_p12> is the pathname to the .p12 file.
    • <Device_PIN> is the hex value of the PIN for your device. Add the prefix 0x. To find the PIN of a device, open the Settings app on your device, tap About, and then select Hardware in the Category drop-down list. Record the value from the PIN field.
    • <password> is the password for the keystore that you used when you registered.
    • <project.bar> is the .bar file for your project.
    blackberry-debugtokenrequest -cskpass <csk_password>  -keystore <pathname_p12>  -deviceID <Device_PIN> 
        -storepass <password> <project.bar>  
  3. Run the following blackberry-deploy tool where:
    • <project.bar> is the .bar file for your project.
    • <yourDeviceIP> is the IP address of your device.
    • <yourDevPassword> is the password for your device.
    blackberry-deploy -installDebugToken <project.bar> -device <yourDeviceIP> -password <yourDevPassword>

Package and deploy your app from the command line

Before you package and deploy your app, make sure you have compiled your code base as binaries.

To package your app onto your device:
  1. Change directory to where your project and code are located.
  2. Run the following blackberry-nativepackager tool where:
    • <native-sample> is the name of your app.
    • <Device-Debug> is the build configuration.
    blackberry-nativepackager -package <native-sample.bar> bar-descriptor.xml -configuration <Device-Debug>

    You can change the build configuration from Device-Release or Device-Debug (a BlackBerry device) to Simulator to run your app on a simulator.

To deploy your app onto your device:
  1. Run the following blackberry-deploy tool where:
    • <IPnumber> is the IP address of your device.
    • <password> is the password for your device.
    • <package_bar_file> is the name of the .bar file that was created during the packaging process.
    blackberry-deploy -installApp -launchApp -device <IPnumber> -password <password> <package_bar_file>

You can deploy to more than one device using blackberry-debugtokenrequest. For example, you can run the following command:

blackberry-debugtokenrequest -storepass <KeystorePassword> 
-devicepin <PIN device 1> -devicepin <PIN device 2> 
-devicepin <PIN device n> <debug_token_file_name.bar>

Last modified: 2013-12-21

comments powered by Disqus