黑莓模拟器:BlackBerry 10 Dev Alpha Simulator
如果没真机BlackBerry DevAlpha device的话,下载地址是developer.blackberry.com
签名申请:BlackBerry signing code keys[blackberry.com] , 如果用模拟器开发的话,这一步不是必须的
QtCreator 2.7 (the required QNX plugin should be enabled by default). You can either clone it[qt.gitorious.org] or download a binary installer from[qt-project.org]. You can also download a recent build from Jenkins[builds.qt-project.org].
First of all, you have to enable development mode to be able to access your device to deploy and test software on it.
Refer to this article to see how to do that: http://developer.blackberry.com/native/documentation/bb10/enable_development_mode.html/
Note: if you’re under Linux, there’s one more step to be able to connect to the target machine: go to Settings->Storage and set “Usb connection” to “Connect to Windows” or “Connect to Mac”.
You need to obtain the BlackBerry signing code keys in order to sign your application, or to create a debugToken to run unsigned applications in development mode. The debugToken enables you to test your application on the device before signing it. Once your application is ready for publishing you should sign it.
Note: if you are using the BlackBerry 10 Dev Alpha Simulator, you don’t need to use the debugToken. So you can skip related steps below.
After you submitted a request to get the BlackBerry code signing keys, you should receive two “.cjs” registration files by email within the next few hours.
“client-RDK-*.csj” �C used to sign your applications and publish to the BlackBerry App World storefront.
“client-PBDT-*.csj” �C used to generate a debug token that you can use to test your application on a device.
Note: if you are using Qt Creator 2.7 or higher, you can register directly using the new BlackBerry Settings page as explained in the next section. So you can skip the instructions below.
Once you receive those files, register them with the RIM Signing Authority using the following command line:
where the “<cjs pin>” is the PIN you specified on the web form when requesting the code signing keys and the “<KeystorePassword>” is a password you specify for the keystore.
For more details about signing please refer to Signing Setup Guide[developer.blackberry.com]
Then you create a debugToken file for your device as follows:
You can find the “<device PIN>” on your device or in simulator under “Settings \-> About \-> Hardware”
Your next steps are to install the new debugToken into your device :
For more details on the debugToken please refer to this article[developer.blackberry.com]
The QtCreator 2.7 brings new features for the BlackBerry 10 plugin (currently called “Qnx”) that enables you to easily create, build, deploy and debug your application directly from the IDE. Please make sure you use the 2.7 version or a recent build of QtCreator. Here are the new features that the BlackBerry 10 plugin provides for 2.7:
Easy setup of the your BlackBerry 10 development environment (Kits, Qt Version, Compiler, …).
Support for the BlackBerry Signing code process to register and create a developer certificate and generate a debugToken to upload your apps into the device.
UI editor for the bar descriptor file to easily manage the application’s appearance and behavior when running on the device.
As previously mentioned you can either download a binary installer[qt-project.org] or clone and build it on your own[qt.gitorious.org].
Note: If you are using QtCreator 2.6 we highly recommend you to download the version 2.7 which hugely simplifies the setup of your BlackBerry 10 plugin. By consequence, we won’t cover the use of QtCreator 2.6 in the current article.
If you already have a QtCreator 2.7 installed on you machine, please follow the steps below:
Select Tools > Options > BlackBerry > NDK (on Mac: Preferences > BlackBerry > NDK) and set the path to your NDK. This will generate a Qt version, a Compiler and two Kits (one for the device and another for the simulator) based on your NDK.
Select Tools > Options > BlackBerry > Keys (on Mac: Preferences > BlackBerry > Keys) to register and create a developer certificate. To register you need to set the path to your registration files and the PIN code you specified when requesting the signing keys.
Select Tools > Options > Devices > Add > Blackberry Device (on Mac: Preferences > Devices > Add > Blackberry Device) to add a BlackBerry Device. You can add either the physical device or the simulator.
Create and upload a debug token bar file when adding the device from the wizard.
Note: The signing code support in QtCreator is under development and will be improved in the future.
You can also download a nightly build of QtCreator from http://builds.qt-project.org.
Unix (Mac/Linux): http://builds.qt-project.org./job/qt-creator-unix-snapshot/
Windows: http://builds.qt-project.org./job/qt-creator-windows-snapshot/
It contains some improvements planned for 2.8 which are not available in the 2.7.x release versions.
Below are few known issues with the Qnx plugin in QtCreator 2.7 release, which should be fixed in the next 2.7.1 release:
If you create a new project, select a BlackBerry Kit and build in a release mode only, QtCreator will fail to create the package as it will try to find the bar-descriptor file in a debug build repository. Make sure you selected a debug build to avoid this issue.
If you create a Qt5 project, QtCreator will generate a bar descriptor in order to create the application’s package. You need to add the following lines to your bar descriptor in order for the application to run correclty:
We recommend to use a nightly Qt Creator build which already contains fixes for the issues above.
You can create a Qt application by selecting one of project templates in the “new project” wizard. Additionally, The BlackBerry plugin provides extra templates for Cascades projects and Qt GUI applications using BlackBerry 10 custom styles.
For example, if you create a Qt Quick Application and use the Kit you defined for BlackBerry Qt Creator will automatically generate a bar descriptor file and ask you if you want to add it into your project. You can then use the bar descriptor UI editor to edit your application’s bar descriptor file.
If you are using Qt5, Qt Creator will generate a bar descriptor file to deploy your Qt5 libraries and create the application’s package. As currenlty Qt5 libraries are not shipped in the BlackBerry 10 devices, you need to deploy them into your package.
The following lines in the generated bar descriptor will copy and deploy your Qt5 libraries, imports and plugins automatically from your Qt5 installation directory:
Note that, for security reasons, the nativepackager doesn’t consider symbolic links. This will cause each Qt library to be copied four times and increase significantly the package size. We will provide in the near future a bar file containing the Qt5 libraries, so that you don’t have to deploy them into your packages.
Note: You can exclude the Qt libraries you don’t use to decrease your package size. For that, you can use the <exclude> element and sepcify the libraries to exclude as shown in the example below:
The “bar-descriptor.xml” file specifies the parameters for identifying, installing, and launching native applications on BlackBerry 10. It mainly contains information about the application author, id, icons and other properties and is used to create the BAR file or BAR package. A BAR package is a installation package of an application for the BlackBerry 10 platform. “BAR” stands for “ B lackberry A pplication a R chive”. For more details please refer to this page[developer.blackberry.com]
QtCreator 2.7 provides a new UI editor to easily edit your bar descriptor and manage your application’s behavior and appearance.
Note: the generated bar descriptor file will be called bar-descriptor.xml and will be used by QtCreator to generate a final bar descriptor in the build directory to package your application.
If you run the application now, QtCreator will create the bar package, connect to the device or to the simulator and launch your application. You can also do these steps using commands in a shell, see the next section for more details.
For performance reasons, the log output from qWarning, qDebug, etc is captured by the “slog2” logging system on BlackBerry 10 instead of plain text files in the file system. In the actual release the messages will appear unfiltered in the “Application Output”.
You can use NDK command line tools to package and deploy your application instead QtCreator if needed:
create the package in devMode:
create the package in Signing mode:
sign your application (not needed in the devMode):
deploy on the device:
in case you don’t like what you see, you can remove the application:
Or just deploy the next version.
These configuration has been tested on Linux Debian Wheezy (64 bits) and Opensuse 12.2 with BB10 Gold NDK and deployment on a Simulator and device.
In order to build Cascades applications, you need to adapt your bar-descriptor.xml file, as well as tweaking Qt Creator settings a bit. From now, we assume that you are able to build a Qt Quick application, and able to deploy it. Those using simulator and that are unable to launch the application, even if it compiles and is deployed, should refer to the next section.
Note that using Cascades in your application is more involved than just adding “import bb.cascades 1.0” to your QML files. See the Cascades Documentation[developer.blackberry.com] to learn how to write Cascades based applications.
When using cascades, some precautions have to be taken for packaging your application. You first have to respect a specific folder layout, where all shipped files, that includes images files like icons, and QML files, should be in a subfolder called assets.
The bar-descriptior.xml file should also be adapted to take the different targets in account. Here is an example of descriptor file including only the simulator as a debug target
You can take inspiration on descriptor files that the SDK generates to get other targets. But take care of the o-g folder in which the debug binaries will be compiled for the simulator. Other binaries have their own folder.
In the project file, you needs to add cascades options. You can also add import path, that provides autocompletion in C++ editor. QML autocompletion does not work out of box for now, but a workaround exists[qt-project.org]. The following template contains all the settings that should be added.
Some additional settings have to be passed to qmake in order to make the compilation to work. First, if you didn’t add the BB10 kit, you should add it. It will provide automatically the compilation recipe and the testing on a device. In order to compile cascades based applications, you need to add a QMake option, that is
for a device, or
for the simulator.
With these options, compiling a cascades based application, and deploying it should work.
Setting the simulator as a device is easy, and can be done as if it was a real device. However, the simulator is X86-based, and the default settings for compiling a Qt project with Qt Creator are those for arm devices. In order to compile for X86, you have to change the MKSPEC, and it is done by passing
to the QMake additionnal arguments. With this spec set, it will override the default spec and compile for X86.
You can add some permission to the application by tweaking the bar-description.xml file by adding the line
or the following line for permission identifier that is mark * in the list below
Here’s a list of permission identifier
Permission �C Identifier
Internet �C access_internet
Location �C access_location_services
Microphone �C record_audio
Notebooks �C access_pimdomain_notebooks
Post Notifications �C post_notification
Push �C _sys_use_consumer_push *
Run when background �C run_when_backgrounded
Shared Files �C access_shared
Text Messages �C access_sms_mms
Blackberry Messenger �C bbm_connect
Calender �C access_pimdomain_calendars
Camera �C use_camera
Contacts �C access_pimdomain_contacts
Device Identifying Information �C read_device_identifying_information
Email and PIN messages �C access_pimdomain_messages
GPS Location �C read_geolocation