processing-android
processing-android copied to clipboard
library data resources not loaded
I noticed that the library third parties data folder in Android mode 3.0.1 get not loaded as it is done in the desktop version, e.g., this library data folder doesn't get loaded in Android whereas it gets loaded in the desktop. A workaround is to include the data folder in all the sketches requiring it which in my case are all of them, as it's done here.
What do you mean data resource are not loaded? Do you get an error?
I mean resources located here are not loaded (it works fine in Processing desktop). Got a:
The file "PickingBuffer.frag" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
and thus they need to be copied to the sketch data folder directly.
By the way, in the case of the rocket texture that comes along with the Processing examples, couldn't load it either even if I locate it within the sketch data folder. Got a:
Couldn't create a reader for /data/user/0/processing.test.frameinteraction/files/rocket.mtl
Everything tested under the Processing Android 3.0.2
You should use the assets folder instead, see how the default shaders are stored in processing-core. Let me know if this solves the issue.
Is it also the place to store specific library custom shaders? Is it location to store other resources like font, data and image files?
I used to locate all of them (including the shaders) under my library data folder (which works fine in Processing-desktop).
ok, I think I was wrong about suggesting the assets folder.
I believe the problem is that if the library contains resource files, it needs to be built as a library project. Android Studio and gradle can use the new AAR format, that allows packing resources, but ant cannot.
For instance, the VR libraries for cardboard contain many resource files, for example the gvr-base package. It is bundled as a zip, and when the mode builds the project using ant, it first unpacks the zip and convert it to a library project https://github.com/processing/processing-android/blob/master/src/processing/mode/android/AndroidBuild.java#L372
Is this of any help?
thanks for your answer, I get a better picture of the issue. Together with issues such as #246 this one seems to me as being part of a broader matter: whether or not should a given library be split for the desktop and android (and even js) modes of Processing. I'm close to be releasing a major Proscene version and I think it'd be simpler and more elegant to not split it at all. I don't see to many cons (see below) in trying to do that, but the situation may perfectly be different for other libraries. In a nutshell, in order to avoid splitting Proscene I only needed to:
- Use a dependency injection pattern for the mouse or the touch agents depending on the platform (desktop or Android) where the library is loaded.
- Use Java 1.7 instead of the latest Java 1.8 which I would have preferred to use.
- Declare a
public boolean surfaceTouchEvent(MotionEvent event)within the sketch body itself of the examples to cope with #246 (see my first comment there). Not too elegant and not too simple. - Add data folders in a per example basis, even if they contain the same library resources. Not too elegant and not too simple either.
I think it should be decided first what library development model to encourage. If that's the case, the processing template library should then need to be refactored, probably among other things. That's my too cents as I know too little about ant or gradle.
I've added item 1 to the list of my previous comment in case someone needs it.