What Mac users call “Bonjour” is really just Apple’s brand name for Zeroconf, a network standard for automatically configuring devices on a local network. Zeroconf also happens to be the best way to get OSC clients to configure themselves without making the user jump through hoops like setting up IP addresses.
Apple actually has a cross-platform Bonjour library for the job, free and Apache-licensed and available for Java. But that library includes a lot of native code, so it’s not going to be a good choice for Android After some initial problems getting it to run on Android which I think I inadvertently caused by bringing in a wrapper class, I’ve now got this pure Java library working on Android:
(A quick search suggests that there are problems with Apple’s library — it’s certainly not being updated — and pure Java is a better tool for the job generally for something like a networking library for Java programmers! So jmDNS it is.)
jmDNS seems to be everyone’s choice at this point, so what’s really needed is … a tutorial. Now that I fixed my own stupid problem, you can look forward to that. Back on it tomorrow/this weekend. And naturally, I might as well use it with OSC and Java and desktops and Processing – because once it’s done, it’ll work all those places.
The instructions for setting up Android development on Linux are pretty Ubuntu-centric. Here’s my basic set of steps to get things going on my shiny, new Fedora partition (which I have to say has been treating me much better — sorry, Ubuntu)!
1. Get Eclipse. Eclipse is available via yum on Fedora; there are even packages for plug-ins. That means you can grab most of what you need as easily as this:
su -c 'yum install eclipse-jdt eclipse-mylyn-java eclipse-mylyn eclipse-subclipse'
(I’m just throwing in a few plug-ins as examples, and very often you need Subversion support to easily pull in sample projects. eclipse-jdt is probably enough, however.)
2. Set the Sun JDK as a default. Okay, technically, you should be able to proceed with the OpenJDK, but you will want Sun JDK for Processing (which eventually we’ll use on Android), and I find it’s a smoother road – at least for now, as the last holes in OpenJDK get plugged.
Mauriat Miranda has written good instructions on how to set up Java and specifically how to configure Sun Java as a default. Just substitute the developer “JDK” for the runtime “JRE” – as on Windows, so long as you install the JDK, you’re set; you don’t need the JRE.
3. Set up Eclipse for its default plug-in repository. Okay, the one and only part of Fedora’s Eclipse setup that’s not very awesome is that it doesn’t set up the default plug-in location. That will mean some plug-in installers won’t be able to find dependencies. No worries, though: just go to Eclipse and select Help > Install New Software > Add… and enter this as a plug-in repository:
http://download.eclipse.org/releases/galileo
4. Install ADT. Set up the Android plug-in for Eclipse as per the usual instructions, with the installer at https://dl-ssl.google.com/android/eclipse/
5. Configure Fedora’s udev rules to support your device in debugging mode. Google correctly tells you to configure Linux so you can connect your phone for debugging, but it assumes you’re running Ubuntu. Here’s what worked for Fedora; perhaps folks familiar with other distros can tell me where else these apply.
You need to edit 51-android.rules, as on Ubuntu, as a super user:
su -
nano /etc/udev/rules.d/51-android.rules
Then add the line of code that will identify your device and place it in the proper mode. Make sure to match your device ID; “22b8″ is Motorola (for my Droid, or any other Moto handset). The list is at the bottom of the device developing page (a must-read): SUBSYSTEM=="usb",SYSFS{idVendor}=="22b8",SYMLINK+="android_adb",MODE="0666"
Finally, in place of the deprecated udevcontrol, reload instead with this: udevadm control --reload-rules
And yes, I’m starting up this blog again — I’ve been busy on Android in the intervening time, but I now have stuff to write about / log / share again! (As you know, I also have some other littleblogs to tend to, but then that means blogging should just be part of thinking by now, right?
Just a friendly reminder — erm, one I needed myself — there’s on additional step to make sure you can test your Android applications on the device. First, on the device, you need to select Home > Menu > Settings > Application > Development > USB Debugging. (Nitpicky issue with the documentation – they accidentally left out Settings.) Then, you need to set up the device on the OS side. On Mac, you just plug it in and it works. On Windows, you do have a driver that must be installed. On Linux, the additional step is to create a rules file:
If you’re developing on Ubuntu Linux, you need to add a rules file:
Login as root and create this file: /etc/udev/rules.d/51-android.rules.
For Gusty/Hardy, edit the file to read:
SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Dapper, edit the file to read:
SUBSYSTEM==”usb_device”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
That rule says “Gusty/Hardy,” but it is true of any version Gusty or later – I just tested it on Ubuntu Jaunty.
Developing on Linux is actually quite nice. I look forward to the point at which Ubuntu lets you run applications on your desktop, too – it should be ideal for testing alternative screen resolutions with a full Android environment, not just what’s available on the in-IDE emulator.
When you get to here, you know you’ve won – this is the 1.5 logo.
The idea of “rooting” an Android phone (giving yourself root-level user access) can be a little scary, especially if you’ve had experience with platforms like iPhone or PSP. On those devices, rooting really is breaking into a device that you only tentatively own. The Android is quite different: while an exploit is needed for root access, the device itself is more open. And the advantages are plentiful: you can install new features before they’re widely available, as well as perform “power user” tasks with wifi and memory management, plus take advantage of hacked multitouch capabilities that are otherwise unavailable.
These are not intended as instructions. For that, I strongly recommend you do what I did and follow the step-by-step tutorial from androidandme. These are extremely lucid and easy to follow, even if this is your first time doing something like this.
What this may help with is knowing what to expect to see on your screen, which isn’t covered in that tutorial, plus a couple of points I almost missed.
As suggested in the tutorial, I’m using the current Ubuntu of custom Android firmwares: JesusFreke.
A quick backup note: you’ll wind up reformatting the SD card, so backup first using MyBackup Pro, then copy that zip to your computer. When done, copy it back and restore. Easy.
I shot this quickly before the presentation at OFFF, just to demo my first quick sensor app. It reads these sensors and uses a standard Java OSC library to transmit the data to a computer via wifi. One little problem is that it seems the G1/Android don’t yet support ad-hoc wifi networks, which limits its utility. But it was interesting to see iPhone developers impressed with the amount of orientation data you can get from Android’s three-axis sensors.
Now I’m working on adding features and porting to the new sensor APIs in Android 1.5.
TMobile should theoretically be pushing out its Cupcake updates now, but I haven’t seen the official update. I also had some reasons to run the “rooted” Android version:
More power over things like tethering, which it looks may also help enable wifi communication as I’m testing this OSC app
Screenshots on the device
Upgrades when I want them in future (handy for development)
The ability to run software off the SD card rather than internal memory (totally absurd that Android doesn’t natively support this, but my internal memory is very much squashed)
I’ll need a backup, largely to retain apps I’ve installed; MyBackup Pro looks quite nice, so just bought that.
Also, androidandme.com, by far the best Android site out there at the moment, has a nice step-by-step rooting guide.
So, with those in hand and a new Kingston 8 GB MicroSD card I got for less than $20, off to the races.
Updated: Done! Very, very easy to do. The whole process took about an hour, but that was while doing some other things – probably 30 minutes if you really focused on it. The only strange bit is the loophole that gives you root access, which requires an exploit that types a command into the device. I could imagine that might get closed in the future, although so far even without root access, Android is a pretty open device. Posting some photos of what the process looks like, but first want to make sure I can get rolling with development.
This is great, as it’ll allow me to test some new sensor stuff, via the refreshed APIs, directly on the device – while at the same time knowing those who don’t want to go this route should get their 1.5 update in the next week or so from TMobile so they can test, too.