This is a two-part question about adding a third-party library (JAR) to an Android project in Eclipse.
The first part of the question is, when I try to add a third-party JAR (library) to my Android project I first get the problem of
Error parsing XML: unbound prefix
because I'm trying to use a class from that JAR (and need the prefix somehow defined). What's going on?
Second, (after fixing that--the answer is given below), my application doesn't work on Android and I discover via the debugger (LogCat) that the class I'm attempting to consume doesn't exist.
Caused by: java.lang.ClassNotFoundException: com.github.droidfu.widgets.WebImageView...
Why, when I get no compilation or linker error in Eclipse, does it have this problem on the emulator?
These two questions are rhetorical for I'm going to answer them myself below. Other posts in this forum creep up to the problem and elsewhere there is discussion, but I feel that I can be more explicitly helpful for the next guy to come along.
Go to build path in eclipse, then click order and export, then check the library/jar, and then click the up button to move it to the top of the list to compile it first.
If you are using the ADT version 22, you need to check the android dependencies and android private libraries in the order&Export tab in the project build path
Ensure that your 3rd party jars are in your projects "libs" folder and they will be put in the .apk when you package your application. You may see runtime errors on the device if something in the jar is not supported, but other than that I have had great success with this.
Put the source in a folder outside yourt workspace. Rightclick in the project-explorer, and select "Import..."
Import the project in your workspace as an Android project. Try to build it, and make sure it is marked as a library project. Also make sure it is build with Google API support, if not you will get compile errors.
Then, in right click on your main project in the project explorer. Select properties, then select Android on the left. In the library section below, click "Add"..
The mapview-balloons library should now be available to add to your project..
First, the problem of the missing prefix.
If you consume something in your layout file that comes from a third party, you may need to consume its prefix as well, something like "droidfu:" which occurs in several places in the XML construct below:
This comes out of the JAR, but you'll also need to add the new "xmlns:droidfu"
or you get the unbound prefix error. For me, this was a failure to copy and paste all of the supplied example from the third-party library's pages.
Setting up a Library Project
A library project is a standard Android project, so you can create a new one in the same way as you would a new application project.
When you are creating the library project, you can select any application name, package, and set other fields as needed, as shown in figure 1.
Next, set the project's properties to indicate that it is a library project:
In the Package Explorer, right-click the library project and select Properties. In the Properties window, select the "Android" properties group at left and locate the Library properties at right. Select the "is Library" checkbox and click Apply. Click OK to close the Properties window. The new project is now marked as a library project. You can begin moving source code and resources into it, as described in the sections below.