The second beta of the Native SDK is now available at native/beta microsite – the corresponding runtime is 126.96.36.19949 – and this post shows how to compile, package, and install the first Hello Graphics Sample using just the command-line.
Download NDK and Prep Your PlayBook
Point your browser to the download page, and download the SDK. The bundle includes the full, Eclipse-based, Momentics IDE and is 400MB; in this post I will only use a few command-line commands, but there is no smaller bundle. Yesterday I encountered some download failures when using Chrome (on MacOS), but Safari worked fine.
The post assumes you have a PlayBook (you can buy one here) so you will not need to download the simulator.
You will need to install the latest 2.0 OS beta on your device as described in Unbox your PlayBook with a 2.0 Twist. You will also need a debug token an you can follow the instructions in Installing a Debug Token on your PlayBook; the NDK has its own copy of the commands used there:
bash-3.2$ blackberry-debugtokenrequest -storepass MYSTOREPASS \ -devicepin MYDEVICEPIN MYDEBUGTOKEN.bar bash-3.2$ blackberry-deploy -installDebugToken MYDEBUGTOKEN.bar \ -device MYDEVICEPIN -password MYDEVICEPASS
Note to create a Debug Token you will need RIM to mail you Signed Keys and that currently can take a couple of hours.
Install the NDK
Install the NDK as usual. I used the default location; in my Mac this was
/Developer/SDKs/bbndk-2.0.0-beta2. The NDK includes a
bbndk-env.sh file that defines needed shell variables including Makefile flags, PATH, targets, etc. You need to source this file so makes and commands work as desired
Download and Compile the Sample
Next, download the sample you want to use from the NDK Sample Apps. In this case we will use the first Graphics samples.
Expand the ZIP file into some new directory, navigate to the subdirectory that is pre-arranged to be compiled via a Makefile, and compile the sources via a single
bash-3.2$ unzip HelloNativeSDK.zip bash-3.2$ cd HelloNativeSDKMakefile bash-3.2$ make
I’ll skip the verbose output but the result is to compile and load the program. The result is in the
x86/ and the
Next we will take the arm/o.le-v7 objects and we will package that into a bar (the format used for PlayBook applications) using the
bar-descriptor.xml. We will also request the bar to be packaged in
devMode, and we will sign it using the
debugToken we have created previously. The sample also includes an icon for the application that will be used in the home screen.
The complete command is as follows:
blackberry-nativepackager -package out.bar -devMode \ -debugToken MYDEBUGTOKEN.bar \ bar-descriptor.xml -list -listManifest \ -e arm/o.le-v7/HelloNativeSDKMakefile HelloNativeSDKMakefile \ icon.png
I added a
-list and a
-listManifest flags to the command so you can see what’s created, but that is not necessary. The resulting bar is
Added – Elena pointed out than rather than indicate any of the assets to include in the bar, use the BAR descriptor using the -D flag:
blackberry-nativepackager -package out.bar -devMode \ -debugToken MYDEBUGTOKEN.bar \ bar-descriptor.xml -list -listManifest \ -D QNX_TARGET=$QNX_TARGET
Note that if you list any assets in the command line that has precedence over the information in the descriptor, so don’t list any.
Before installing into the PlayBook, remember to put it in Developer Mode, to note its device address, to assign – and remember – a device password, and to upload the same debugToken we used above onto it. All this is described in Installing a Debug Token on your PlayBook.
And now you are ready, just need to:
blackberry-nativepackager -installApp \ -device MYDEVICEIP -password MYDEVICEPASS \ out.bar
Note that you do not need to connect the device via a USB cable; plain WiFi will work.
And that’s it. You should see something like:
Info: Sending request: Install Info: Action: Install Info: File size: 21620 Info: Installing ... Info: Processing 21620 bytes actual_dname::com.example.HelloNativeSDKMakefile.testDev_SDKMakefile15be26ac actual_id::testDev_SDKMakefile15be26ac actual_version::188.8.131.52 result::success
After this your PlayBook should have the application. Launch it and you will see…