I finished an app like a month ago which uses the JSoup jar in it. commonsWares pointed out to me that I need to remove the jar file from the build path and create a libs folder for proper usage.
I removed it from the build path and created a folder called libs and placed the jar file in there. Is this correct?
The android project is returning error because it can't see the JSoup library. So how do I do this to ensure its all visible and working well?
A screenshot of what I have done is below:
It sounds like you may not be on the latest ADT.
The latest ADT should just pick up any jar in your library.
Every time you move a jar file's location you need to update the build path. In Eclipse, you should right click on the project, select Build Path then Configure Build Path. Then just select the Libraries tab, and then Add Jar. Find your jar file and select it and you should be good to go.
Related
I'm trying to use an external jar file in my Android project, I follwed this step for including it:
I put the jar file in libs.
I configured the build path and now I can see the jar file in the Referenced Libraries section of the project.
I use the import to bring the class that I need inside the program.
But I always get NoClassDefFoundError. This jar already works with a classic java program.
Make sure that the jar is being built with the app. In eclipse,
right click on project --> build path --> configure build path.
Make sure the library is checked in the Order and Export tab.
Since Android SDK 17 there is not even necessary to manually add the jar files to buildpath, because they are added automatically, as stated here. Then I would suggest to:
remove the library from buildpath
clean the project
make sure the jar file is located in a folder called libs (not lib) located in the root folder of your project
refresh the project
run the project
The solution found was recompile the library with the version 6 of java and using the jar fail obtained
I tried everything I found posted on Stack Overflow and yet I'm still getting the annoying NoClassDefFoundException when I try to test on the emulator:
I copied the jar to the "libs" directory of the android project
I added the jar to the build path using Add Jar NOT add external jar
I ticked the jar in the export tab
I even tried to compile the jar once with JDK 1.6; still the same annoying exception. The jar I'm referring to just contains a few entity objects I created for another project, and would like to re-use with my Android project.
By the way, I also tried to add the jar as an external jar, but didn't work either.
You need to add it to the assets/ directory along with adding it to build path in that location for it to work. Do remember to pick the same jar when adding external library.
See this thread
NoClassDefFound Error comes in java, when some class is not available on runtime, while it was available at compile time, please check what is source of this error, you can use following blog to get assistance:
http://javarevisited.blogspot.in/2011/06/noclassdeffounderror-exception-in.html
Do the following ::
Go to the project properties >> Java Build Path add jar file as external jar.
Select order and export option >> select the libraries and jars of the project.
If not working change the order of jar make sure its above android dependencies .
I deleted a jar from my libs file and now I cannot build the project and the jar will not go away.
I've tried cleaning the project, fixing the android properties now I'm stuck.
Has anyone else had this problem?
Description Resource Path Location Type
Archive for required library: 'C:/apps/APP/libs/imagecrop.jar' in project 'APP' cannot be read or is not a valid ZIP file APP Build path Build Path Problem
Solution.
Don't use clean or "fix project properties"
Simply right click on the project and press "Refresh"..
You need to remove it from your build path. Right click your project, go to Properties->Build Path. The build path contains four tabs:
The Java Build Path properties page contains four tabs:
Source. The source and output folders. If you initially create a project without separate source and output folders, you can change it here. Multiple source folders can be used in one project; e.g., to separate application source code from unit tests.
Projects. Check-off other projects in the workspace whose output folders should be added to this build path.
Libraries. Location of other archive files required by this project.
Order and Export. Order in which projects and libraries appear in the build path and the default runtime classpath; e.g., use classes from a workspace project before using the same classes from an archive library.
Go to libraries tab and remove the jar file you deleted.
Also refresh your project by right click -> Refresh so it will realize you deleted jar file.
I am working on an app which uses Commonslang.jar libraries. I was trying to setup it on a new system with newly installed Eclipse.The project is not showing any error But when I run the project it force closes with NoClassDefFoundError at each point where I use Commonslang lib.
I dont know how to fix this problem.Please help?
I think there are "lib" folder in your project directory so just change it "libs" instead of "lib" and clean project and check it..
> Note: No need to build path for any third party library
You need to create libs folder in your project and copy that jar file there. Then in eclipse, right-click on that jar file (which is in libs folder) select Build Path and then select Add to Build Path.
Remember: if you are using a jar file in your Android Library Project, and associating that library project with your regular UI
project, it won't be enough. You must need to include that jar file
(as described above) in both of your projects (Android Library and UI
project) to make it work.
Have you added the jar to the Java Build Path?
Go to the Properties for the Project and select Java Build Path -> Libraries tab then add the external jar there.
This is a follow-up to this question: "android can't find class from external jar"
I have an Android project in Eclipse that uses an external JAR. The JAR is extremely simple: it contains a "toy" class that computes a square of a number and returns the result as a String.
BAD: If I create the JAR in Eclipse by creating a regular Java project with the class, then exporting it into a jar file, and finally adding this JAR to the build path of the Android project, I get a run time exception that this class cannot be found.
GOOD: If I create the JAR in Netbeans and add that JAR to the build path (in Eclipse), all works well.
I actually unzipped both jars to compare contents. It appears that the difference is in .class files but they are not human readable so I can't get any further.
So my q is this: what can I change in the Eclipse export to make the external jar "good"? What is NB doing right that Eclipse is doing wrong? Or do I simply resort to building all my external JARs in NB?
Thanks
In the "Order and Export" tab of your Build Path screen, check the box for the missing jar
If your problem is linked to the ADT 17, the easiest workaround is to create a directory libs in your project and copy your jar into it. see link