Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robolectric 3.8 java.util.zip.ZipException

I'm trying to upgrade my android project to sdk 27 and so I tried to upgraded robolectric to 3.8. Now I'm hanging on that error when I try to run my tests:

java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file

at org.robolectric.res.Fs$JarFs.<init>(Fs.java:96)
at org.robolectric.res.Fs.fromJar(Fs.java:27)
at org.robolectric.internal.SdkEnvironment.createRuntimeSdkResourcePath(SdkEnvironment.java:31)
at org.robolectric.internal.SdkEnvironment.getSystemResourceTable(SdkEnvironment.java:22)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:332)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:245)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.robolectric.res.Fs$JarFs.<init>(Fs.java:94)
... 27 more

I think the interesting part of my gradle looks like that:

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.3'
  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 27
  }
}

dependencies {
  testImplementation 'org.robolectric:robolectric:3.8'
}

I already tried to clean my dependencies and deleting my gradle wrapper. I appreciate every tip you can give me, ty. If you need more information to be able helping me just ask for it.

like image 231
Pascal Stech Avatar asked Jan 24 '26 12:01

Pascal Stech


2 Answers

Delete the .gradle directories in both your home directory and in your project's root directory and try building again.(from:Error when I try to generate a libgdx projet)

like image 162
Shyam Sasidharan Avatar answered Jan 27 '26 03:01

Shyam Sasidharan


Delete the cache files in your maven cache. eg. my directory ~/.m2/repository/org/robolectric/android-all/8.1.0-robolectric-4611349

like image 23
Haiyang.Wu Avatar answered Jan 27 '26 01:01

Haiyang.Wu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!