Asset Loading Issues with Android Eclipse Integration (OSX)

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

Sign In or Register to comment.