Add your jar file to the folder app/libs . Then right click the jar file and click "add as library". You can then expand your Project to find the "libs" folder or right click your project and make a new directory. You can then move the JAR file for your library into that directory using your OS file manager.
Now for the missing class problem.
I'm an Eclipse Java EE developer and have been in the habit for many years of adding third-party libraries via the "User Library" mechanism in Build Path. Of course, there are at least 3 ways to add a third-party library, the one I use is the most elegant, in my humble opinion.
This will not work, however, for Android, whose Dalvik "JVM" cannot handle an ordinary Java-compiled class, but must have it converted to a special format. This does not happen when you add a library in the way I'm wont to do it.
Instead, follow the (widely available) instructions for importing the third-party library, then adding it using Build Path (which makes it known to Eclipse for compilation purposes). Here is the step-by-step:
NOTE
Step 5 may not be needed, if the lib is already included in your build path. Just ensure that its existence first before adding it.
What you've done here accomplishes two things:
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.
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.
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
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:
<com.github.droidfu.widgets.WebImageView android:id="@+id/webimage"
android:layout_width="75dip"
android:layout_height="75dip"
android:background="#CCC"
droidfu:autoLoad="true"
droidfu:imageUrl="http://www.android.com/images/opensourceprojec.gif"
droidfu:progressDrawable="..."
/>
This comes out of the JAR, but you'll also need to add the new "xmlns:droidfu"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:droidfu="http://github.com/droidfu/schema"
...>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With