I've written a little app and have been successfully running in my Android devices via the native IDE for a few months. But earlier this year when I updated Processing (or the Java sdk) it stops compiling.
I eventually figured out why (kind of) and made it work, and thought it might be useful for you guys. The build error messages I got were something like:
1. uses unchecked or unsafe operations ... recompile with "-Xlint:unchecked" for details" 2. trouble processing "java/security/Provider.class": ... Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library
Turns out it was a two-step problem.
For 1), make sure all the ArrayList objects you created in the file has a type, so "ArrayList myList = new ArrayList();" does not work anymore, and should instead look like "ArrayList<PVector> myList = new ArrayList<PVector>();. If the problem persists or you really want to use the -Xlint:unchecked option, there is a way:
Have Ant installed and properly set up. Go to your Android sdk->ant folder (e.g. C:\Program Files\Android\android-sdk\tools\ant\) and copy of the "build.xml" file, paste it to the exported application folder of your project with the name as "custom-rules.xml". Inside, look for the property with the name "java.compilerargs" and set the value to "-Xlint:unchecked". Then in the "build.xml" file comment out the {$sdk.dir}/tools/ant/build.xml import tag so only the file you just copied and modified will be used.
This is a rather tedious way and you have to do the same thing everytime you export a new folder. But it seems that the Processing IDE doesn't have that option.
For 2), turns out the Processing version I have automatically added the "android.jar" library when exporting the project (it's in the "libs" folder). All you need to do is to remove it.
But the catch is I couldn't find a simple way to install my the application into my device -- once I click that "play" button everything is done automatically again and there is no way I can skip the inclusion of this jar file, which causes the conflict. So I had to resort to the command-line approach:
Open a command prompt and navigate to the Android sdk platform-tools directory for the "adb" tool, or set your system path to include that. Then use the command:
adb -d install <your_app>-debug.apk
I'm not sure if I've missed some settings from the IDE and caught myself in those steps, but those are the steps I took and it worked. I guess the developers can at least look into the automatic inclusion of the "android.jar" library which seems to be the cause of the build failure.
I'm working on a Processing library that responds to touch events on Android.
I've written a class that implements the OnTouchListener and with the onTouch abstract method implemented.
Now I need to set an object of this class to listen to touch events (using the View.setOnTouchListener). However, this method requires a View parameter, which I believe should be the PApplet being "touched". I wonder how can I get the reference of this View parameter that receives touches and will then start passing touch events to my class.
Or if there is another way to do that?
I guess once Processing for Android supports registerMethod("touchEvent", target) this won't be necessary.