# How to create android library eclipse?

**URL:** <https://discourse.processing.org/t/how-to-create-android-library-eclipse/28638>\
**Category:** Processing for Android\
**Created:** [March 18, 2021, 1:30pm UTC](https://discourse.processing.org/t/how-to-create-android-library-eclipse/28638 "2021-03-18T13:30:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 18, 2021, 1:30pm UTC](https://discourse.processing.org/t/how-to-create-android-library-eclipse/28638/1 "2021-03-18T13:30:55Z")

</div>

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

> **[paulgoux/androidGuiLibrary](https://github.com/paulgoux/androidGuiLibrary)**
>
> android Gui Processing Library. Contribute to paulgoux/androidGuiLibrary development by creating an account on GitHub.

which contains the following java files.

> **[paulgoux/windowsGui](https://github.com/paulgoux/windowsGui)**
>
> Contribute to paulgoux/windowsGui development by creating an account on GitHub.

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/](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

```auto
//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

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 20, 2021, 12:26am UTC](https://discourse.processing.org/t/how-to-create-android-library-eclipse/28638/2 "2021-03-20T00:26:07Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 20, 2021, 1:08am UTC](https://discourse.processing.org/t/how-to-create-android-library-eclipse/28638/3 "2021-03-20T01:08:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 20, 2021, 3:34pm UTC](https://discourse.processing.org/t/how-to-create-android-library-eclipse/28638/4 "2021-03-20T15:34:24Z")

</div>

Furthermore and honestly i feel silly now. Visit the processing github as they have a template here for android processing lib

> **[processing/processing-android-library-template](https://github.com/processing/processing-android-library-template)**
>
> Processing Android Library Template for Eclipse. Contribute to processing/processing-android-library-template development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 20, 2021, 6:48pm UTC](https://discourse.processing.org/t/how-to-create-android-library-eclipse/28638/5 "2021-03-20T18:48:38Z")

</div>

here is my fully working repo

> **[paulgoux/processing-android-library-template](https://github.com/paulgoux/processing-android-library-template)**
>
> processing android library template. Contribute to paulgoux/processing-android-library-template development by creating an account on GitHub.

just make sure to amend the .project file if you want to change the folder name and

```auto
classpath.libraries.location=${user.home}/Documents/Processing/libraries

```

to reflect the location of your processing sketchbook folder

and to change

```auto
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.
