A Simple Android Processing Painting Sketch

Processing Android Painting App
Processing Android Painting App

The Coursera class Creative Programming for Digital Media & Mobile Apps started this week and it's been quite a challenging week. Not because of the course content. The challenge has been getting Processing to work in Android development mode in conjunction with the Android SDK and my Samsung Galaxy Tab 2 tablet. The class forums are besieged with posts from people trying to get all these parts to work together. It took some doing but I did get everything working and wrote my first Android app – a simple painting program. The illustration above is a screen shot of the app in action. The app also plays music while drawing – as opposed to playing continuously.

My Processing Android Installation

I am developing using the just released version of Processing (PROCESSING 2.0 (REV 0218) – 3 June 2013) on a Windows 7 platform and using a Samsung Galaxy Tab 2 as my Android tablet. This is relevant because the path to success depends on your particular mix of operating system, Processing version, and Android tablet type. Here are the steps I took to get everything working for my development environment.

1 – Install Processing 2.0, Revision 0218

Installing the 32-bit version of Processing went off without a hitch. I started Processing and created a couple of test sketches to insure that this piece worked.

2 – Use Processing's Add Mode tool to add the Android and Javascript operating modes.

Abject failure. It turns out that this new release of Processing has a bug in it such that this tool may or may not work. The Add Mode step is necessary if you want to use Processing to develop apps.

2b – Manually add the Android mode

I manually downloaded the Processing Android development library from
The big question was where to unzip it. The instructions said ‘in the modes directory' but I had more than one. I tried adding it to the ‘canned' locations people were recommending but those didn't work for me. If I had done it right Processing would have recognized the library's existence and added it to its modes options list.

The reason the canned solutions did not work for me is because I had specified my own directory for Processing to use as its Sketchbook library. When I did this, Processing automatically (and without telling me) created a modes subdirectory in that directory. That is the modes directory in which Processing will look for the libraries. So if you're a Processing user and want to know where your modes directory is, go to File -> Preferences and look at the entry for the Sketchbook location to see where this is on your computer.

At this point, Processing now had an Android mode but when I tried to use it, Processing told me that it didn't know where my Android SDK was. Note that at this point I had not even installed it.

3 – Install the Android SDK

I installed the Android SDK and next using the SDK Manager downloaded and installed a variety of packages. I then restarted Processing and upon entering Android mode told Processing where I had installed the Android SDK. Processing stores this path in your preferences.txt file, in my case as:
android.sdk.path=C:\Program Files (x86)\Android\android-sdk

I now tried to run a sketch in emulator mode (Sketch -> Run in Emulator) but bailed after staring at a "Waiting for device to become available" message forever. What to do?

3b – Re-Install the Android SDK

I uninstalling the Android SDK and started over from scratch. Only this time I used the instructions found here:
on how to install the Android SDK. Note that the installation of the SDK takes a long time to complete so be sure to have something to do to keep yourself occupied while the install runs its course.

At the conclusion of this process, I had an Android SDK with the following packages installed:

  • Tools:
    • Android SDK Tools
    • Android SDK Platform-tools
    • Android SDK Build-tools
  • Android 4.2.2 (API 17)
    • Documentation for Android SDK
    • SDK Platform
    • Samples for SDK
    • ARM EABI v7a System Image
    • Google APIs
    • Sources for Android SDK
  • Android 2.3.3 (API 10) SDK Platform
  • Extras: Android Support Library
  • Extras: Google USB Driver

I went back to Processing and again tried to run a sketch in Emulator mode. Success! But be forewarned – the emulator is slow to get going. The first time I bailed as I was still getting the "Waiting for device to become available" message. It turns out I was just not being patient enough. The second time the emulator window finally showed up and after waiting some more, my sketch started running in the emulator.

4 – Running the Sketch on my Tablet

Now it was time to try and run my sketch on my Android tablet (Sketch ->Run on device). The first thing I did was go into my tablet's settings and set the Developer Options -> USB Debugging to ‘checked'. I plugged my tablet into my laptop and in Processing hit the Run button. Note that Processing defaults to running your app on the attached device. After going through the compilation stage I was once again seeing my old friend: "Waiting for device to become available". Now what? I was patient but realized that my patience was not going to pay off when the message "Lost connection with device while launching. Try again." showed up.

One step in the troubleshooting process was to make sure that the AndroidManifest.xml file for my sketch contained the following line: "android:debuggable=”true”" in the application section – it did.

Going back through documentation I saw that there was one thing I had neglected to do.

5 – Install Device Drivers for my Galaxy Tab Tablet

The reason Processing couldn't talk to my tablet was that I'm using Windows and if you are on the Windows OS you need to download and install USB drivers from your tablet's manufacturer that can then be used by the Android SDK (ADB). I found the information on this part of the process here:

So it was off to find the downloads page for my tablet on the Samsung web site. You won't find any reference to USB drivers there but you will find the Kies software package that runs on your PC and gives you the ability to manage your tablet. For example, this is the software you would use to install firmware updates on your tablet.

The Samsung Kies install takes some time to complete. In fact it is even slower than the Android SDK installation process. Additionally, on starting up Kies it told me that a newer version was available! So I had to go through a time-consuming update. I was told by a Samsung rep that the Kies software that people download from the Samsung web site is not kept up to date so everyone downloading Samsung Kies will encounter this need to update.

Getting the Samsung Kies software to talk to my Galaxy tablet required some troubleshooting which involved Kies reinstalling its drivers and rebooting. Having gotten Kies to connect with my tablet, I took the opportunity to update my tablet's firmware.

At this point, rather than continue with the installation instructions previously referenced, I gambled. I started Processing and tried to run a sketch without completing the steps about installing the USB drivers.

Success! Processing connected to my tablet, downloaded the sketch, and the next thing I know I'm finger painting.

My Processing Android App Plans

Now that I've gone through all this pain to write and run Android apps, what am I going to do with this capability? That's a good question. According to the Creative Programming for Digital Media & Mobile Apps course outline, the topics that will be covered are:

  • Week 1: Introduction: sonic painter
  • Week 2: Interactive D/VJ app
  • Week 3: Music player and sensor controlled visualiser
  • Week 4: Game with physical modelling and synthesis
  • Week 5: APIs accessing and processing social media data
  • Week 6: Music machine

Obviously I'm going to write apps that satisfy the course requirements. But beyond that I have no plans for developing Android apps. Rather I am primarily interested in using this class as a source of new ideas for digital creativity. But who knows – by the end of the course I may have a different perspective.

Happy computing, Jim

| Return to the Blog Index | This entry was posted on Thursday, June 13th, 2013 at 10:15 am and is filed under computer art, Computing, Digital Art, Processing.