Packaging and deploying apps

You can use the QNX Momentics 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 a simulator.

Package and deploy using the IDE

Once 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:

  • Get code signing keys and debug token creation keys
  • Set Development Mode on your device to On
  • Connect your device to your computer or start your simulator
  • Run the BlackBerry Deployment Setup Wizard
See Set up your environment for details.

To package and deploy your app:

  1. In the Project Explorer view, expand your project and double-click bar-descriptor.xml.
  2. To set the author information for the app, when the descriptor 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 the OS on your device to the most recent version of the OS when possible or the OS version that matches your customer's environment.

See Debug your app and Profiling an application for more build options.

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 a command window, on Windows you can enter echo %APPDATA%. The location should be similar to D:\Users\[your userid]\AppData\Local\Research In Motion.
  • Get code signing keys
  • Set Development Mode on your device to On
  • Connect your device to your computer or start your simulator
  • Run the BlackBerry Deployment Setup Wizard
See Set up your environment for details.

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 Using a proxy server in 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 register your keys.

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 code signing keys from the command line

You need to register with the RIM Signing Authority using the CSJ registration files for app signing by using the blackberry-signer tool. you only need to register your keys once.

To register your code signing keys:

  1. Run the following blackberry-signer tool where:
    • <csj-pin> is the PIN you specified on the web form when you requested code signing keys.
    • <password> is a password that you specify for the keystore.
    • <client-PBDT-xxxxxxx.csj> is the pathname to the app signing .csj file sent by email after you registered.
    • <client-RDK-xxxxxxx.csj> is the pathname to the debug token .csj file sent by email after you registered.
blackberry-signer -register -csjpin <csj-pin> -storepass <password>
               <client-PBDT-xxxxxxx.csj> <client-RDK-xxxxxxx.csj>

After you register your keys 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.

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 theBAR 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:

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