We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I have a Android Processing sketch that used to work a few years ago but I need to update it and can't get it to run. It seems like there is a problem with having the path in the filename string but this used to work..
Any idea how to work around this problem? Ideally I would like to keep my code as is and figure out how to make it run on my device.
Thanks
Phil
FATAL EXCEPTION: GLThread 787
Process: processing.test.pixelpetal_v09, PID: 1579
java.lang.IllegalArgumentException: File sequences/allseq_pixelData/pixelData00000.png contains a path separator
at android.app.ContextImpl.makeFilename(ContextImpl.java:2366)
at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:1120)
at android.content.ContextWrapper.getFileStreamPath(ContextWrapper.java:191)
at processing.core.PApplet.sketchPath(Unknown Source)
at processing.core.PApplet.createInputRaw(Unknown Source)
at processing.core.PApplet.createInput(Unknown Source)
at processing.core.PApplet.loadImage(Unknown Source)
at processing.test.pixelpetal_v09.pixelpetal_v09.loadImageSequence(pixelpetal_v09.java:96)
at processing.test.pixelpetal_v09.pixelpetal_v09.setup(pixelpetal_v09.java:116)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
Answers
please note that there is a new forum now
please ask there
https://forum.processing.org/two/discussion/27995/new-forum
Are you using the environment from two years ago or are you using the latest Android mode in Processing? If using the latest, some of your code might need to be changed. You need to provide the code showing enough details about the operation that is failing.
Kf
Thanks @kfajer, since I last had it working I have a new laptop and had to fully re-install Processing and the Android SDK.
I believe that originally I may have used Processing 2.2 and this time I'm trying to use Processing 3.3.
The code that seems to be causing the issue is below... specifically it's the "loadimage" that seems to error.
Cheers Phil
for (int i=0; i<numFrames; i++) { String imageName = "sequences/" + basename + "_pixelData/pixelData" + nf(i, 5) + ".png"; imageSequence[i] = loadImage(imageName); println("Image "+imageName+" was loaded as "+imageSequence[i]); }
Please add the code at the end of the this post to your sketch. This code will limit your sketch, so you can only run it in Processing android mode.
The imports can be placed in the top of your file. This function can be placed at the end of your pde file AND in the same scope as
setup()
anddraw()
. This is a quick solution to overpass the error of the file separator that is observed when accessing these resources the way you do.Note, your pictures need to be place under the data folder:
Your sketch folder should look like this:
I use this loadImage like this:
Kf
@philspitler I forgot to mention, you need the above override function if you want to keep your folder structure:
String imageName = "sequences/" + basename + "_pixelData/pixelData" + nf(i, 5) + ".png";
However, if you drop the folders, you can place all the images inside the data folder and the standard call to
loadImage()
should work without any modification.Kf
Thanks Kfrajer, I tried the code and got errors while compiling...
And here is my sketch....
Any ideas?
Thanks again.
Phil
Not sure why that is happening in your case. Surface is one of the internal java classes that should be present in the core.jar. I have few suggestions:
Go into your sketch folder and rename your manifest file. Build your code again and Processing should regenerate a new manifest.
A second suggestion: If you run a simple sketch, similar to: https://android.processing.org/tutorials/getting_started/index.html does it work?
Finally, try this:
stream = getActivity().getAssets().open(filename);
Kf
Amazing.... we are getting much closer...
Regenerating the manifest didn't help...
Running the sample code did work.
And then modifying the stream as you suggested got us much closer.
The app launches on the device for a moment and then errors and quits with the following message...
FATAL EXCEPTION: GLThread 1202 Process: processing.test.pixelpetal_v09, PID: 12673 java.lang.NullPointerException: src == null at java.lang.System.arraycopy(Native Method) at processing.opengl.PGraphicsOpenGL.setImpl(Unknown Source) at processing.core.PImage.set(Unknown Source) at processing.opengl.PGraphicsOpenGL.backgroundImpl(Unknown Source) at processing.core.PGraphics.background(Unknown Source) at processing.core.PApplet.background(Unknown Source) at processing.test.pixelpetal_v09.pixelpetal_v09.draw(pixelpetal_v09.java:247) at processing.core.PApplet.handleDraw(Unknown Source) at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
Actually I went back to a previous version of my sketch, applied your new code and it doesn't give me those errors any more... We are REALLY close now...
The issue now is with font rendering and CP5
My font code looks like this..
And the error I get is:
Inefficient font rendering: use createFont() with a TTF/OTF instead of loadFont().
Actually... the above message is just a warning and I "think" that things are working correctly.... I will know more tomorrow when I get test again...
HUGE thanks...
Phil
@Phil It is great to know what it is working. Thxs for keeping us updated. I will see you in the new forum as this one will go offline anytime soon.
All the best,
Kf
@kfrajer, thanks so much for your help... this works perfectly...
I'm very curious why this changed since I wrote my original sketch but I'm VERY happy it's working again..
Phil