We have now managed to create and run our first Marmalade application, but running it on Windows isn't our ultimate goal. The whole reason for the Marmalade SDK is to make it easy for us to develop our application once and then deploy it on a whole range of mobile device platforms.
Of course we might need to alter some of our assets, for example, because we are targeting a wide range of different screen resolutions and want our application to look its best at all times, the code itself should need no modification in order to run successfully.
To illustrate this, we will now take the "Hello World" project and get it running on a number of different mobile device platforms.
Running our project in Windows meant we were compiling our code using the standard Visual C++ compiler and therefore generating Intel x86 code. However, it is a fact that the vast majority of mobile devices available today contain some version or other of the ARM processor, so the first thing we need to do is compile our code for ARM.
Luckily, Marmalade has made this incredibly easy for us. At the top of the Visual C++ window, you should see a drop-down box that defaults to a setting called (x86) Debug.
If you open the drop-down box, you will see several build types pre-configured for us, but the one we are interested in is the GCC (ARM) Release option. Select this and build the solution again (Build | Build Solution or press F7), and Visual C++ will use the GCC compiler to create an ARM version of our application.
Now we just need to get the code onto a device!
Now that we have an ARM-compiled version of our code, we need to create an install package so we can test it on a real mobile device. To do this we need to use Marmalade System Deployment Tool. Follow these steps to go through the deployment process:
The Package and Install options available in the Marmalade System Configuration Tool often rely on your system being set up with extra third-party software that isn't automatically installed as part of the Marmalade SDK. For this reason in this book, we will generally keep to using the Package option and install and run our deployment packages using manual methods.
The default location for the deployment packages is within the Marmalade Build
directory. If you use Windows Explorer to look into this directory, you will see that a new directory called deployments
has been created. In turn, this directory contains a folder called default
, which comes from the deployment configuration we used.
The default
directory contains subdirectories for each of our selected deployment platforms, and each of these will contain a release
directory since it was the release build that we created the deployments from. Note that it is also possible to deploy a debug build, which can be useful when debugging. Go into the release
folder and there you will find our freshly made deployment package.
All that is left to do now is to install and run it on a device.
Let's start by looking at how to install an Android build.
Before being able to make an Android deployment with the deployment tool, there is a prerequisite that the Java JDK must be installed. You can download this from the following web page:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
The Android package file for the "Hello World" project is called Hello.apk
, and to install it we first need to copy it to an Android device. This can be done by copying the file to an SD card, or if your device has built-in storage memory, copying the file into that.
Before we can install our package, we first need to make sure that the Android device will allow us to do so. Go into your device's Settings program and select the Applications option. Here there is an Unknown sources option, which allows us to install our own packages. Make sure this option is ticked.
Next find the file manager application on your device. Different devices may have different names for this application, but it often has an icon with a picture of a filing cabinet folder on it. Navigate the directories to find the location where you copied the Hello.apk
file, then tap on the file's entry in the list.
The screen will change to show a big list of things that the application is asking to access, along with the Install and Cancel buttons. Click on the Install button and the package will be installed. You can then choose the Open button to start your application, or the Done button if you don't want to run it now. Click on Open and we should then be greeted with our Hello Android! message.
By installing the Android SDK, it is also possible to speed up testing on the device by allowing the deployment tool to automatically package, install, and run the deployed package. Instructions on setting up the Android SDK so this will work can be found in Chapter 10, Extending Marmalade with the Extensions Development Kit (EDK) of this book.
If you've tried to create an iOS build of the "Hello World" project, you will have noticed that it currently fails to complete with a signing error. This is because you will need to provide Marmalade with some certificate files, which can only be generated by becoming a registered Apple developer.
Joining the iOS Developer Program currently costs $99 per year, and you can find more details about it at the following web page:
https://developer.apple.com/programs/which-program/
Once you've signed up, you'll be able to access the iOS Dev Center that will then allow you to create the required certificates. Normally you would require an Apple Mac to generate these certificates, but, handily, Marmalade provides a small utility called the iPhone Sign Request Tool that gets around this issue. Here is what you need to do:
s3edeploypluginsiphonecertificates
of your Marmalade SDK installation.developer_identity.cer
.com.domainname.appname
. The domainname
part can be pretty much anything you like (it doesn't necessarily have to relate to a real URL), while the appname
part should either be the name of your application, or you can use an asterisk that then lets you use that App ID for any application.There is more information on this process in the Marmalade Documentation help file, and there are also How To tabs on most of the iOS Provisioning Portal pages explaining the processes involved, although most of these assume that you are using an Apple Mac to generate the various files.
With all those hurdles negotiated, we can then use Marmalade System Deployment Tool to generate a properly signed iOS install package, which will be named Hello.ipa
. Now to get it installed onto a device!
It is possible to use iTunes to install your builds, but be warned that it tends to be a little bit of hit and miss as to whether it will work. Sometimes iTunes does not recognize that a new build is available and needs to be synched to the device. In my experience, a more reliable option is to use the iPhone Configuration Utility , which is a freely available Apple tool that can be downloaded from the following URL:
http://support.apple.com/kb/DL1466
First of all, you need to let the iPhone Configuration Utility know about your provisioning profile. Click on Provisioning Profiles in the far left pane and then click on the Add button in the toolbar. Navigate to the provisioning profile file you created in step 9 and click the Open button to add it to the list of available profiles. Alternatively, you can drag-and-drop the file into the list from Windows Explorer.
Next, click on the Applications entry in the left-hand panel and then click on the Add button. Find the Hello.ipa
file in the deployment's release
directory and click on OK to add it to the list of known applications, or again you can drag-and-drop the file from Windows Explorer into the list.
Now connect your iOS device to your computer using a USB cable. It should appear in the bottom of the left-hand pane after a short delay. Click on the name of your device and you should see five tabs appear in the main panel. Click the Provisioning Profiles tab and then click on the Install button next to your provisioning profile. Once done, this button will change to become a Remove button.
Our next step is to install the application itself, so click on the Applications tab to see a list of all applications that are either installed on the device already, or which can be installed. Find the entry labeled Hello and click on its Install button, which will change to read Remove once the application is installed.
After all that, we can finally run our application by finding its icon on the device and tapping on it. You should see the message Hello iOS!, which I admit may seem like something of an anticlimax after going through such a drawn-out process.
Marmalade can also deploy to BlackBerry QNX devices, the best known of which is the PlayBook tablet. In order to deploy to PlayBook, we need to do some setup work first. In the steps that follow, there are some commandlines that need to be entered. In these commandlines there are some arguments enclosed in angled brackets. After each set of commands, there is a table explaining what to replace the angle-bracketed arguments with.
C:PlayBook
for the following steps.PATH
environment variable so that the other commands can be executed. These commands register your key files with the BlackBerry signing servers and allow your PC to generate debug tokens:C:PlayBook> C:bndk-2.0.1bndk-env.bat C:PlayBook> blackberry-keytool -genkeypair -keystore sigtool.p12 -storepass <password> -dname "cn=<company name>" -alias author C:PlayBook> blackberry-signer -csksetup -cskpass <password> C:PlayBook> blackberry-signer -register -csjpin <pin> -cskpass <password> <RDK file> C:PlayBook> blackberry-debugtokenrequest.bat -register -cskpass <password> -csjpin <pin> <PBDT file>
Argument |
Value to enter |
---|---|
|
The company name you specified when requesting the key files in step 4. |
|
A password of your choosing. Use the same value in each command. |
|
The filename of the PBDT key file that was e-mailed to you in step 6. This filename should be of the form |
|
The PIN value you specified when requesting the key files in step 4. |
|
The filename of the RDK key file that was e-mailed to you in step 6. This filename should be of the form |
C:PlayBook> blackberry-debugtokenrequest -cskpass <password> -keystore sigtool.p12 -storepass <password> -deviceId 0x<device id> debugtoken.bar
Argument |
Value to enter |
---|---|
|
The device ID of your BlackBerry device. As an example, you can find out this value on a PlayBook by going into the settings screen, clicking on the About item in the left-hand pane, and selecting the Hardware option in the drop-down box. The value labeled PIN is the device ID. When you specify this value in the commandline, make sure you prefix it with |
|
This is the same password you used in the previous set of commands. |
C:PlayBook> blackberry-deploy -installDebugToken debugtoken.bar -device <ip address> -password <device password>
Argument |
Value to Enter |
---|---|
|
The device password you set in step 10. |
|
The IP address of the device as discovered in step 9. |
deployments
sections of the MKB file, to allow us to make a valid deployment package:playbook-author="<company name>" playbook-authorid="<author id>"
Argument |
Value to Enter |
---|---|
|
The company name value you specified when requesting the key files in step 4. |
|
Finding the value for this is a little convoluted. First make a copy of the |
The build should now be installed on the device, so breathe a sigh of relief and then look for its icon in the applications list. Touch the icon to run the program, and you should be greeted with the merry little message Hello BlackBerry!
Installing a build on to a Bada device is one example where using the Package, Install and Run option in Marmalade System Deployment Tool is actually a very good idea, as it is not possible to copy the package to a Bada device manually to install it.
To begin with, you need to install some device drivers for your Bada device so that the deployment tool can connect to it. Marmalade does ship with some drivers for Bada, but working out which of the three possible drivers matches your device can be hard to work out. For this reason, it is better to first install the Samsung Kies utility, which comes with a number of drivers and will install the correct one for you automatically. You can download Kies from the following web address:
http://www.samsung.com/uk/support/usefulsoftware/KIES/JSP
After installing Kies, connect your device to your computer with a USB cable and run the deployment tool. When you get to the platform selection page, you will see that there are four possible options for Bada. You must select the correct one for your device, which is based on both the version of Bada your device has and also its screen resolution.
Having chosen the correct Bada platform option, click on the Next Stage > button and then choose Package, Install and Run in the drop-down box at the top of the window. Click on the Deploy All button and an install package will be made, which is installed on to your device and executed, and you should then see the Hello Bada! message in all its monochrome glory!
18.226.98.208