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.
Related
i have a requirement like i have to use one app for two other applications. so i want to create a library project as jar file so that i can use that in build path easily with out adding the project. so i have added my main project as a library project so it has generated jar file in bin folder . so i have copied that jar file and added to libs and added that to my project build path. but still i am getting no class def found exception. please sugest whether this process of generating a jar file is correct or not. if it is not correct please suggest me how to do.
Rightclick on the library project, export -> Jar file.
Select all files, except the AndroidManifest.xml.
Make sure you DON'T select manifest file. Else it will lead to conflict errors.
Now include this JAR file in the build path, and it will work. I did the same.
Let me know if you have any issues.
The Most Important thing , your project doesn't contain any Resources (RES folder) then
1- Right Click on Project –> Export —> Java –> JarFile
2-Select only the src checkbox ie the (pacakages) in Top-Left Window.
Don’t Select anything in Top-Right Window if some thing is selected remove marks .
3-Select Only Export generates Class Files and Resources
4-In Options Select only Compress the contents of the jar file (it's not important)
To add your External Jar to Your File
1-Right click on project –> Select Properties –> Java Build Path —> libraries –> Add External Jar Files –> Click OK
2-CLEAN your Project
You can export your project as a jar.To do this
right click your project->export->java->JAR file->Next
But if you use resources in the library project then you won't get it from the jar.But it will be available if you use as a library project rather than jar
You cannot export a library project to a JAR file
A library cannot be distributed as a binary file (such as a JAR file). This will be added in a future version of the SDK Tools.
Source
You need to do following:
Add reference of .jar file to your client application. Right click project -> properties -> Click 'Java Build Path' -> open Libraries tab -> Click button 'Add External JARs..' and select the .Jar file that you have created -> Go to 'Order and Export' tab and select the Added external Jar and move it to the top.
I hope this will help you.
Mark +1 if it is helpful to you.
I am trying to compile a java project which makes uses of android libraries. The project I am using is checked out from a svn repository.
In order to take a use of that project I am required to define some jar files and libraries for that project.
Here are the files that I need to make sure they are defined:
•"lib/apache-mime4j-0.4.jar" : Jar
•"lib/httpmime-4.0-beta1.jar" : Jar
•"lib/slf4j-android-1.5.8.jar" : Jar
•"JUnit 4.libraryclasspath" : Library
•"ANDROID_SDK_PLATFORM/android.jar" : var
•"Java JRE System Library" : Library
Does anyone have any idea about what should I do to define these files? I am a noob here.I do not know which selection should I choose When I clicked "project -> properties -> java build path -> libraries"
For example if I want to define the first jar file, there are a "add external jar" and a "add libraries" selections.
However you can see a "lib" here in front of the "apache-mime4j0.4.jar file" in this list above..
So I don't understand if it is asking me to add a jar file or the librabry.. I am getting very confused about this.
And also How can I do anything with "JUnit 4.libraryclasspath" file? I think it is a classpath file so I cannot either choose "add jar files" or "add libraries" to define it..
Hope someone has any knowledge about this and I will be very appreciated!
I think You are unable to include the files due to SVN path but will discuss it later.At first we look how to add jar files
Right click on your project in which you want to add the jars
1.select build path and then "configure build path"
2.click on "Libraries" tab
3.Now click on Add external jars (as your all jars files would be placed in some directory outside the project folder or anywhere else)
4.Select these jars and now do OK ... Now these jars are in your class path and you can use these files.
Now another thing, As You told that you are using svn , It means many of other developers are also using the same project then it is compulsory that all of you have same path of jars in your systems for instance in Dev1 PC the jar if the jar file is placed in d:/lib/jars folder then all other DEV2 , DEV3 ... DEVn must have d:/lib/jars folder and their jars must be placed there and you have to add these jars from d:/libs/jars
Last thing , If you are still unable to understand the solution and remove the bugs then simply do this.
Copy all jar files manually (ctrl+c) and copy to lib folder in your project as i have seen that in your project the person who commits the code place them there.
after then , right click on your project and click refresh(as it is bad practice to put jar files in project by creating folder like lib etc unless it is a web project)
Let me know if anything is unclear about this
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.
I'm working on an Android project and i need to import an XML library called XOM. The only way i found was to right click on the project name -> Properties -> Libraries tab -> click on "Add external Jar". But that only references it from it's original path, what happens when i compile the app and move it to my phone? Will the Jar be in there?
Might be a stupid question, sorry if that's the case.
It's fine to do that but what I normally do is create a folder called liband then add Jars from there. I find that makes it easier to see what Jars I have in my application.
The main disadvantage of your original approach is that what if the path to that library externally accidentally changes? then your program will not compile. It's better to have everything in the one place to make things easier.
.apk is nothing but a collection or zipped version of a file. it contains all the resources and compiled java files.
So you need not have to worry about the inclusion of your library files. if you have set proper path to your libraries in eclipse then these will be included in your apk file.
Create a directory called "libs" in your under your root directory. You can do it by,
Right click on the project which is in the Package Explorer window in
Eclipse.
New -> Folder -> give "libs" as the Folder name
Copy your jar file and paste it to in the "libs" folder
Expand the "libs" folder
Right click on your copied jar file -> Build Path -> Add to build
path
That's it
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.