Hi everyone I’m hoping one of you can help please. I’ve been racking my brain trying to figure out how to extend my library to android. I already have a library
which contains the following java files.
Initially I just added the android libraries to my project and build path, and this seemed to clear up some of the code, however as I now understand traditionally the sketch extends PApplet whereas with android the sketch extends and therefore my current code wasn’t compatible.
Having then used google to do a preliminary search I’m trying to follow the following example
https://blog.onthewings.net/2013/04/25/setting-up-a-processing-android-project-in-eclipse/
to get this running, however I run into problems.
having created the package and imported all required libraries and jars, the main activity window produces this error
//The declared package "com.androidgui" does not match the expected package "androidGui"
package com.androidgui;
import android.R;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//main cannot be resolved or is not a field
}
}
I’m thinking I’m probably overthinking this, but as its my first time creating an android library and I’ve only been using eclipse for a week I feel I might be missing something simple.
Many thanks
Paul
1 Like
So having taken a look at the ketai library I found that the core.jar file which it uses is a modified one to the original, which makes sense considering that it has to have android components.
One problem though is that this still does not allow me to mix the classes together. In one jar PApplet has missing variables and therefore I cannot compile using just one or the other I would need both, with only some classes making use of certain jars.
Is this something that is doable ?
Ok so jar files can be opened as zips extracted rezipped, so I took the amended processing core, and then re-added all the other missing classes and then rejar’d (lol). This resulted in a successful build. I shall check tomorrow if the lib works though, for now time for sleep.
Furthermore and honestly i feel silly now. Visit the processing github as they have a template here for android processing lib
here is my fully working repo
just make sure to amend the .project file if you want to change the folder name and
classpath.libraries.location=${user.home}/Documents/Processing/libraries
to reflect the location of your processing sketchbook folder
and to change
classpath.local.location=${user.home}/Dcouments/processing-library-template-master/lib
to reflect the location where you want to place your library build files
Then just use ant to build.
As for the one provided by processing I could not get it to work.
Just bear in mind that only the final library file should be used and the core.jar should be deleted as it will cause conflicts either that or simply drag the final jar file to your code folder.