Adding external JARs to Android Projects in Netbeans (nbandroid - kenai)
A very annoying issue that I've noticed with the NBAndroid Netbeans plugin, is that it doesn't know how to properly attach an external JAR file to an Android Project.
If you right-click on libraries (under your project folder), and click on 'Add JAR/Folder', it will add a reference to that library/JAR file, which it will recognize in the code (detect all the classes, etc). The problem lies when you try to compile the project - at that point, it doesn't actually add the JAR to the project, which in turn gives you errors when running.
It actually took me quite awhile to find a solution for this, and an annoying one at that.
In order to correct this, you'll have to open up your build.xml file (which is under your project folder, but hidden in the netbeans environment). I had to open up my file explorer (Finder on my mac :-)), and go to the project folder and open it up from there.
Add the following bit under your import file tag:
<target name="-pre-jar">
<copy todir="${build.classes.dir}">
<fileset dir="/path/to/your/jar/directory" />
</copy>
</target>
So, if your JAR is in /home/bla/myjars/lala.jar then your path should be "/home/bla/myjars".
Now, try recompiling it and it should work fine.










