Setting up a Processing Android project in Eclipse

Processing, Android, Eclipse

Processing is written in Java, and it plays very well with the Android platform. Every serious programmer knows that the Processing IDE is far from being a proper IDE, and the official Android IDE is Eclipse, so we better stick to Eclipse.

To setup a Processing Android project in Eclipse, follow these steps:

  1. Setup a normal Eclipse Android project, such that we can run a simple hello world with a blank activity, targeting Android API 10+.
  2. Download Processing 2.0+.
  3. Copy android-core.zip to the libs folder as android-core.jar inside our Eclipse Android project (Yes, rename to .jar).
    The location of android-core.zip is:

  • Right-click the Eclipse Android project, properties. Choose Java Build Path, under the Libraries tab, click Add JARs… button. Choose the android-core.jar we’ve copied in previous step.

  • Modify the MainActivity class such that it extends processing.core.PApplet instead of android.app.Activity:

    package net.onthewings.android; //the package of MainActivity
    
    import processing.core.*;
    
    public class MainActivity extends PApplet { //PApplet in fact extends android.app.Activity
        public void setup() {
            /*...*/
        }
    
        public void draw() {
            /*...*/
        }
    }
    
  • Run the project and you should see a blank full screen app :)

  • Notice that it is not even necessary to use additional Eclipse plug-in like proclipsing. By coding in plain Java, we can mix the Processing drawing API with the Android API easily. Additional Processing Android details can be found at http://wiki.processing.org/w/Android.

    comments powered by Disqus