10

I try to

react-native run-android 

and meet this problem

JS server already running.
Running C:\Users\丶丶困困兽兽犹犹斗斗\AppData\Local\Android\sdk/platform-tools/adb -s 192.168.76.101:5555 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && gradlew.bat installDebug...
Unzipping C:\Users\丶丶困困兽兽犹犹斗斗\.gradle\wrapper\dists\gradle-2.4-all\6r4uqcc6ovnq6ac6s0txzcpc0\gradle-2.4-all.zip to C:\Users\丶丶困困兽兽犹犹斗斗\.gradle\wrapper\dists\gradle-2.4-all\6r4uqcc6ovnq6ac6s0txzcpc0Exception in thread "main"    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:114)
    at java.util.zip.ZipFile.<init>(ZipFile.java:131)
    at org.gradle.wrapper.Install.unzip(Install.java:159)
    at org.gradle.wrapper.Install.access$500(Install.java:26)
    at org.gradle.wrapper.Install$1.call(Install.java:69)
    at org.gradle.wrapper.Install$1.call(Install.java:46)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:46)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

SDK works well and can find device in adb devices

Wenpeng Qu
  • 101
  • 1
  • 1
  • 3

10 Answers10

19

The problem is Unable to Unzip your gradle-2.4-all.zip, So please Delete the existing file

gradle-2.4-all.zip

from your folder :

C:\Users\丶丶困困兽兽犹犹斗斗.gradle\wrapper\dists\gradle-2.4-all\6r4uqcc6ovnq6ac6s0txzcpc0\

Download a fresh gradle-2.4-all.zip file and place it on the same folder as we deleted and try again to run your code : react-native run-android

It may work.You can download gradle zip file from the below Link: https://services.gradle.org/distributions

Muhammed Suhail
  • 269
  • 2
  • 6
12

I have the same problem as yours! Because when I first run "react-native run-android", my INTERNET is SLOW and LAG, CORRUPTED. This bad internet connection lets to download a TEMPORARY DAMAGE file gradle....zip. Solution: Just go in that path contains that file zip, delete it then run again! It worked for me!

6

Well, I meet the same problem.

I use this method solve it.

I input: sudo react-native run-android

then the Terminal show :

java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

So I copy a "local.properties" from an existing Android project and put it in this project.

And then,I input sudo react-native run-android again.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Mr.Fish
  • 61
  • 3
4

Content in file gradle-2.4-all error. Please delete content in gradle-2.4-all (~/.gradle\wrapper\dists\gradle-2.4-all...) then re-compile .. it will auto download file.

2

I just experienced the same problem as yours. When I run react-native run-android, I got the error message:

Exception in thread "main" java.util.zip.ZipException: error in opening zip file

I use Mac and apparently the problem was caused by the react-native CLI that is failed to write the Gradle zip file to certain folder due to lack of permission. In my case, I tried to ran the command again this time using sudo: sudo react-native run-android, and the problem was solved.

yunhasnawa
  • 815
  • 1
  • 14
  • 30
1

The gradle-2.4-all.zip was damaged,so it should be replaced with a new gradle-2.4-all.zip

CodeReaper
  • 5,988
  • 3
  • 35
  • 56
fc.c
  • 11
  • 1
1

One of the causes of this problem (since late 2019) is the decommissioning of HTTP services by Gradle. This means that if your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file has an entry like:

distributionUrl=http\://services.gradle.org/distributions/gradle-{version}.zip

... then this entry will try to retrieve a ZIP file from a service no longer servicing it (http based one) and it will silently return an empty ZIP file; which consequentially will be the source of an error from any process trying to unzip that empty ZIP file.

To fix this, just change your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file to have its distributionUrl entry to use https:

distributionUrl=https\://services.gradle.org/distributions/gradle-{version}.zip

Hope this helps.

update the line in ../android/gradle/wrapper/gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

Marco R.
  • 2,667
  • 15
  • 33
0

I think you could download the gradle-2.4-all.zip from here,unzip it to your .gradle.

s__
  • 9,270
  • 3
  • 27
  • 45
0

For me I just deleted .gradle folder and then tried again. It re-downloaded libraries and it worked.

P.S.

I think in new configuration there is no .zip file.

gprathour
  • 14,813
  • 5
  • 66
  • 90
0

The problem is the same as you.

Exception in thread "main" java.util.zip.ZipException: error in opening zip file.

just use sudo react-native run-android insted of react-native run-android