Teaser: Processing is Coming to Android

The remarkable thing about Processing on Android is that you can use your (desktop) sketchbook development environment as always, then run on the Google emulator or your device.

Google’s open-source Android mobile platform runs on Java. Processing, the elegant coding language for visualization, art, and media, is built in Java. The marriage of the two, therefore, is one we’ve long been anticipating. Processing’s ability to focus on lightweight, portable implementation is a perfect match for the demands of mobile development. For artists and visualists wanting to make handheld devices and tablets more expressive, I have good news: it’s coming. While not fully implemented or ready for widespread testing yet, Processing is in active development on the platform.

Ben Fry, co-creator of Processing, has been hard at work making Processing run on Android. Interestingly, in some ways Android itself vindicates the direction Processing charted years ago. Google made their platform work based on open-source development tools. They removed parts of the Java platform that would have overwhelmed the limited processing power of handhelds – even as a handful of purist Java developers cried foul. Graphics focuses on lightweight 2D and OpenGL drawing output, much in the same way that Processing strips Java to its bare essentials.

Best of all, doing Processing development for Android promises the same streamlined, sketchbook-like production flow that Processing does on desktop. To create Android apps, you simply set Processing to “Android mode.” (Right now, you have to point to Google’s SDK, but that happens only once and may be removed in future versions.) Hit run, and your sketch launches in the Emulator. Plug in an Android device via USB, and it’ll run on your device. Soon, you should have one-click-export of apps in the way that you do Processing desktop apps.

This also suggests some great possibilities for cheap, handheld devices, installations, and reliable portable devices for visual performance. Sure, right now a lot of Android-powered devices require a phone contract and don’t output video, but a lot of devices slated for later this year are media devices with video output and tablets, too.

Processing for Android is an early work-in-progress. If you’re thinking about playing with it and you don’t know what you’re doing, or you have little patience for bugs and wrinkles, you should wait until the waters grow safer. Right now, the team working on testing the port is intended to be limited, although as someone testing it myself, I can say it’s already a lot of fun and holds a lot of promise for the future. OpenGL support is currently not available, but it’s coming – and I’ll say again, if you want to know what Processing’s 3D future looks like, check out the superb GLGraphics library. Anyone who thinks Processing can’t be fast, or do intensive GPU work, or mix HD video (okay, not on Android, but on desktop at least), check out this library. OpenCL should also be possible soon.

BIG, BIG disclaimers! Please don’t go testing Processing on Android assuming it’ll work out of the box – for the brave ONLY, at least for now. (That should change very, very soon, but I couldn’t keep the news under my hat any longer.) As the disclaimer says (hilariously):

Do not use this code while operating heavy equipment. Do not rely on this code for thesis or diploma work, as you will not graduate. Do not use this code if you’re prone to whining about incomplete software that you download for free.

A number of us have already begun talking about the possibility of adding libraries to connect Processing’s capabilities to Google’s own APIs for the phone, SMS, sensors, and so on. Sound and synthesis via external libraries should also be possible.

I think Processing for Android is the perfect complement to openFrameworks for native code on mobile platforms. Right now, OF has already been used for terrific work on the iPhone. It’s not quite as user-friendly as Processing for Android for a number of reasons, but it has Processing-derived syntax, aesthetics, and philosophy, and it’s also free and open. For a superb guide to developing on the iPhone with OF, plus some links:

OF does not appear to be a practical solution for Android development, not least because Android requires apps to be distributed as Java, and uses Java to talk to all the native APIs. But it’s a good option for some of these other devices, and you can run the two alongside one another in Eclipse if you like, more advanced users.

With OF on the iPhone (and presumably other native platforms in future – Nokia N900, anyone?), and Processing for Android, plus tools like Pd and SuperCollider for synthesis (more on that soon), there’s no reason not to go completely open with portable interactive art on mobile devices.

Just tested this out of the box w/ a Macbook Pro and a rooted G1 and it worked out of the box! You can take the compiled .apk in some instances and drag it over via sdcard and it will run w/o error! More testing is in order…

You shouldn't have to have a rooted phone, actually, but it may need to add signing from within the Processing application. (Even that should be possible with Eclipse.) Certain advantages of Android over, cough, devices than rhyme with "My Scone." 😉

1 example then is hopefully we can make simple reactive visuals that interact with motion, mic and the camera…. a kind of processing styled rjdj for instance

im excited about the possibilities and again just proves to me that i chose right in sitting patiently with my android waiting for the good and free and open stuff to come along so that us users can do exactly what we want with our mobile devices

Well on the N900 front it doesn't have java support out of the box though it seems someone has managed to compile and run Java on maemo. No word om how well it runs though, i should imagine not very well.

The Android tool in Processing is extremely simple to use. Even the Beta mode works flawlessly on my HTC Desire. Running a sketch uses the Android emulator and Present mode runs over USB on your phone.
Once you are happy with the sketch you simply export it and sign the generated apk file with your own signature. You then need to install the apk on your phone and it works like any other application. Due to some bug in Android OS (?) all sketches run in full screen mode but that isnt much of a problem. It can even switch to horizontal using a simple if statement!
If you just change the width and height variables most sketches can be run on an Android phone.
I am delighted with this Beta addition to Processing and when its finished it will be awesome!

sci

Hello Rosie,

I'm trying to get this up and running on my HTC desire and I'm having a real hard time. I downloaded the SDK unpacked it and put it in my applications directory, opened the SDK and AVD Manager went to available packages and downloaded the lot just to be sure…. all to no avail! When I select Android Mode in Processing (pre release) I have a message saying "Done loading Android tools" which is good. I then click run and KABOOM. An alert box appears saying "An error occurred while running "android create avd" to set the default Android emulator. Make sure that the Android SDK is installed properly, and that the Android and Google APIs are installed for level 6" then loads of red error messages: