We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Problem: My Android app seems to be crashing when I try to use calls like loadFont(file) or loadImage(file), where file is something sitting in my project's assets directory.
Background: I've been successfully using Processing integrated with Eclipse for a while now on Ubuntu (12.04 32bit Processing/Eclipse/Java). I've done this by following some blog posts where you just copy the processing-core.jar (renamed from zip) into your Eclipse project's library folder, and add the JAR to the build path. Then, you set the activity to extends PApplet, and then it just works (define your setup()/draw() functions inside the activity, and you're good to go).
I recently transitioned to OSX from Ubuntu, and for the large part, the above seems to work fine, up until I try loading anything from the assets folder.
Here is some example code that works on my Ubuntu setup, but not here:
package com.example.processing_test1;
import processing.core.PApplet;
import processing.core.PFont;
import processing.core.PImage;
public class MainActivity extends PApplet {
PFont f;
PImage p;
public void setup(){
f = loadFont("OpenDyslexic-Regular-48.vlw");
p = loadImage("nav_down.png");
}
public void draw(){
background(255);
fill(0);
textAlign(CENTER,CENTER);
text("TESTING", width/2, height/2);
}
}
where the files are sitting in my assets directory. with the loadFont call, I get an error saying that the file couldn't be found. With the loadImage call, it raises a null-pointer exception. If I remove the loading calls, the app runs fine and produces the text. Any thoughts?
Answers
Bump.
Bump. Still at a total loss.
Bumping again. Still haven't gotten anywhere on this.
SORTED. The assets I was testing with were corrupted files from a transfer between the two machines. It wasn't obvious at first because Eclipse doesn't show file-sizes. A more detailed write-up is posted here:
https://stackoverflow.com/questions/23503653/android-assets-not-found-issues-in-both-eclipse-android-studio-using-processing/24199346#24199346