Getting started with Firefox OS
Book of FoxChapter3 ▼
Deploying your app
Once you have a running app, next steps are:
-
experience the app on a real device
-
spread it around so others can enjoy it too
Testing on the device
Now that you know how to write and debug an application and also test in the simulator, you're naturally eager to see it running on a real device. Good news: you can do this easily using the R2D2B2G extension. Bad news: there's some setup upfront.
adb
You'll need to setup a command-line utility called adb
which stands for Android Debug Bridge. You run this utility on your development machine and use it to connect to your phone, to browse the file system and copy (pull, push) files between the computer and the phone.
R2D2B2G comes with a copy of adb so you don't have to install it separately. However you have to setup the phone and the computer to "talk" to each other.
First, enable remote debugging on the phone: go to the Settings app, then select menu Device Information / More Information / Developer. Once there, check the "Remote debugging" option.
Then you need to setup your developer machine. The setup is different depending on your operating system.
If you're on a Mac, the good news is that it just works. On Windows you need to install drivers specific to your computer manufacturer. The details can be found here: https://developer.android.com/tools/extras/oem-usb.html
On Linux you need to create the file:
/etc/udev/rules.d/51-android.rules
In this file add the line:
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
The id string 05c6
is specific to the phone you have, so you may need to replace it with the one for your test phone. Here are some IDs you might find useful:
-
05c6
- Geeksphone device made by Qualcomm -
19d2
- ZTE device, the maker of several test devices, e.g. Unagi, Inagi and Otoro -
18d1
- Google device -
04e8
- Samsung
Finally, set the permissions:
chmod a+r /etc/udev/rules.d/51-android.rules
If all goes as planned, when you open the R2D2B2G extension you'll see the new option to push the app to the device.
Standalone adb
It's great that R2D2B2G comes bundled with adb. But if you run into troubles with the setup (and you're not sure if the extension's UI is to blame) or if you want more hands-on development, it will be beneficial to install your own copy of adb.
To do so:
-
Download the "ADT bundle" zip file from http://developer.android.com/sdk/index.html (ADT stands for Android Developer Tools)
-
Unzip to a convenient location, e.g.
~/Codez/adt
-
Add the path to the subdirectory
sdk/platform-tools
found in ADT to your OS PATH. This is where the adb utility is found and it's good to have it handy.
For example, after unzipping the ADT bundle in your ~/Downloads
folder:
$ mv ~/Downloads/adt-bundle-mac-x86_64-20130219 ~/Codez/adt $ export PATH=~/Codez/adt/sdk/platform-tools:$PATH
The end result you're looking for is being able to type adb devices
from any directory and make sure it "sees" your phone.
$ adb devices List of devices attached full_unagi device
Then, just for fun, try adb shell
and just like that, miraculously, you can browse the files on your phone.
Pushing the app to the phone
Once the setup is behind you, things can't be any easier. Open the R2D2B2G dashboard and click the "Push" button found next to your app.
The phone will ask you for permission to accept a remote connection. Say OK.
And this is it. You'll see an "Battery installed" message and the app is now available on your phone.