Reputation: 68915
Before coming to the problem let me explain what I did that has landed me in the problem.
C:\Users\Aniket\Documents\GitHub\Android
(This folder has the .git
folder in it).TicTacToe
go to Team->Share Project
and provide my repository path i.e C:\Users\Aniket\Documents\GitHub\Android
.But my project is suddenly showing error with a red '!' sign on it.
Description --> Archive for required library: 'C:/Users/Aniket/AndroidWorkspace/TicTacToe /libs/android-support-v4.jar' in project 'TicTacToe' cannot be read or is not a valid ZIP file
Resource --> TicTacToe
Path Location --> Build path
Type --> Build Path Problem
Note : the Error was a single line displayed in error console on Eclipse. I just split it up for readability.
Even after detaching repository it shows that error.
Has anyone encountered this scenario before. What is the solution or workaround? I googled and first few links suggest it is an Eclipse bug. Please suggest what can be done to bring my project back to executable state?
Upvotes: 29
Views: 74422
Reputation: 102
I realize this is an old question, but I have yet another solution if none of these work for other people coming across this thread. I had this same problem, and spent alot of time trying to figure it out, only to find that my Eclipse classpath/buildpath has a .json file in it, it doesn't like that, so it wouldn't compile. So, check to make sure no text files or json files, etc are in your build path.
Upvotes: 0
Reputation: 1996
It is an Eclipse bug. I have faced the similar problem several times. closing and reopening the project works sometime. if it doesn't work try restarting Eclipse.
Upvotes: 49
Reputation: 9
I was stacked on this problem for days despite searching for a solution on the net. I first moved my project to Netbeans and all worked fine. I then returned to eclipse->properties->java compile-> Building and changed "Incompartible build path" option from error to warning and then did maven update and it worked.
Upvotes: 0
Reputation: 987
I will say that it can be that some answers work for some cases, but for me it was necessary to go an extra mile. So I will try to make a summary of what can be done:
Verify that the jars are intact:
jar tf myjar.jar
Restart eclipse and update projects setting over right click on project -> Maven -> Update project
The option which has work for me was to navigate in the workspace folder and then delete the files:
.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache
.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache
After that restart eclipse and rebuild project.
Upvotes: 1
Reputation: 1712
For Java web application, web.xml added as jar in the project. In project explorer, try to find web.xml as in jar icon and remove from the project. Error will go away!!
Upvotes: 0
Reputation: 326
i was facing same problem in Eclipse Mars. I downloaded the jars from [https://oss.jfrog.org/webapp/#/artifacts/browse/tree/General/repo/org/ethereum/ethereumj-core/1.0.0-SNAPSHOT][1] and replaced it in the directory.
I got error while adding ethereum.jar using pom.xml at C:\Users{machineName}.m2\repository\org\ethereum\ethereumj-core\1.0.0-SNAPSHOT\ethereum-core-1.0.0-SNAPSHOT.jar , i added the downloaded jar(ethereum-core-1.0.0-SNAPSHOT.jar) here and the problem was solved.
Upvotes: 1
Reputation: 3831
For us, the problem seemed to be the size of the .jar file. I would recommend doing the following test to see whether this is the case or at least rule it out. First have a look at other jars in your Eclipse project and compare them to the problemetic jar. Is it a lot bigger than the others? If so, try the following workaround. Else, this answer probably won't help you. Before starting, configure Windows to treat .jar files as .zip files with the following command line command:
assoc .jar=CompressedFolder
(see https://superuser.com/questions/121540/can-you-configure-windows-to-open-jar-files-like-zip-files-without-a-3rd-party-t)
Before trying the workaround, here is a test to see if it is indeed the jar file size that's tripping you up.
If it is indeed size that's the problem, which you might have identified by doing the optional simple test above, you can try the following workaround.
The steps might be a bit unclear, so here's an example. Imagine your jar file was called mylib.jar. You unzip this to a folder called mylib. Inside, let's say there are three sub-folders called package1, package2 and package3. Create 3 folders called mylib1, mylib2 and mylib3, and put in package1, package2 and package3 respectively. Then zip these up and rename extension to .jar. You'll then be importing mylib1.jar, mylib2.jar and mylib3.jar.
Upvotes: 0
Reputation: 1383
In my case, the java installation was not proper. So, I uninstalled Java and reinstalled a new version. Now, it works.
Upvotes: 0
Reputation: 4750
Could be due to corrupted jar files as well. Better to check that first as that was the reason in my case:
jar tf myjar.jar
should list the content inside.
Upvotes: 1
Reputation: 535
Looks like everyone has different story to tell! For me, I had to delete the error from eclipse Markers tab, and then cleaned the project again. Before that, I closed and re-opened the project/eclipse several times as suggested by @rachit, which did not work for me.
Upvotes: 6
Reputation: 2480
A solution that worked for me:
go to *.classpath
and delete the line :
<classpathentry kind="lib" path="the_problematic_class.java"/>
Upvotes: 1
Reputation: 972
In my case restarting Eclipse did not solve the problem. I restarted the computer and did a Project -> Clean
in eclipse
Upvotes: 1
Reputation: 4297
I found no duplicates anywhere and tried restarting eclipse, rebuild project. I was getting error for only one libary. So I just tried to rename the jar file from ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar
to ksoap2-2.5.8.jar
So if none of the problems solves from above you can also try this one
Upvotes: 0
Reputation: 631
In my case I tried all the tips suggested but the error remained. I solved changing version with a more recent one and writing that in the pom.xml. After this everything is now ok.
Upvotes: 1
Reputation: 1354
In my case, i'd downloaded project from internet, after unzipping project some files had been blocked, just unblock files and try again, then problem was solved.
Upvotes: 1
Reputation: 4411
There is other case to display error Archive for required library
Right click on project and open --> project project properties --> java build path --> Android private libs
if there are two jar files with same name then remove one from libs.
jar file may the hidden some times then open you libs folder in window and check if any hidden files are exist Organize --> folders and search options --> view --> check show hidden files and Delete the hidden jar file , The same cass delete if hidden java fies exist in src and packages if any
Upvotes: 10
Reputation: 1676
I've seen the same issue. I removed that jar file, and then rightclick on the project, select maven, and do "update project...". The jar was downloaded again, and the problem was gone.
Upvotes: 22