archive for required library could not be read or is not a valid ZIP file

后端 未结 18 2267
醉梦人生
醉梦人生 2020-12-03 04:27

Before coming to the problem let me explain what I did that has landed me in the problem.

  1. I created an account on github and made a repository named Android.
相关标签:
18条回答
  • 2020-12-03 05:01

    In my case restarting Eclipse did not solve the problem. I restarted the computer and did a Project -> Clean in eclipse

    0 讨论(0)
  • 2020-12-03 05:01

    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:

    1. Verify that the jars are intact:

      jar tf myjar.jar

    2. Restart eclipse and update projects setting over right click on project -> Maven -> Update project

    3. 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.

    0 讨论(0)
  • 2020-12-03 05:04

    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.

    0 讨论(0)
  • 2020-12-03 05:05

    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.

    0 讨论(0)
  • 2020-12-03 05:08

    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.

    0 讨论(0)
  • 2020-12-03 05:08

    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)

    Optional: A simple Test

    Before trying the workaround, here is a test to see if it is indeed the jar file size that's tripping you up.

    1. Create a large .jar full of random .class files that aren't in your problematic jar. You can do this by making a folder full of files, zipping it, and renaming the .zip extension to a .jar. Windows might warn you about changing the extension. Ignore this. Make sure you have enough files in the folder so that it's a bit larger than the problematic jar.
    2. Try to import this artificially created jar. If it fails with the same error, then size is probably the issue.

    The Workaround

    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.

    1. Decompress your .jar file. You should be able to do this easily in Windows
    2. Split the folder you get from step 1 into smaller sub-folders. It could be just two folders, or more, depending on how big the original is. You want the folders to be smaller than some of your existing "good" jars so that size won't be an issue. Make sure to keep the package structure intact when you're doing this.
    3. Zip up all the folders you created in step 2, and rename the .zip to .jar.
    4. Import all of the .jars from step 3 individually.

    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.

    0 讨论(0)
提交回复
热议问题