我一直在尝试设置运行我的第一个反应原生项目并遵循提供的步骤here。但是当我运行
时,我不断收到此错误$ react-native run-android
我得到的是这个
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Unzipping /home/webshinobis/.gradle/wrapper/dists/gradle-2.4-all/6r4uqcc6ovnq6ac6s0txzcpc0/gradle-2.4-all.zip to /home/webshinobis/.gradle/wrapper/dists/gradle-2.4-all/6r4uqcc6ovnq6ac6s0txzcpc0
Exception 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:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.zip.ZipFile.<init>(ZipFile.java:163)
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)
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
我已经搜索过,到目前为止我所看到的都是genymotion用户解决方案。
有关如何解决这个问题的想法吗?
答案 0 :(得分:2)
哦,我发现错误,
中的zip文件/home/webshinobis/.gradle/wrapper/dists/gradle-2.4-all/6r4uqcc6ovnq6ac6s0txzcpc0/gradle-2.4-all.zip
是腐败的,因为它无法被java解压缩。 所以我必须进入文件夹并删除zip文件mannualy然后运行
react-native run-android
一次。希望能帮助别人。这通常是由于互联网连接问题造成的。
答案 1 :(得分:0)
设置ANDROID_HOME
个环境变量。首先检查您的adb devices
。如果您的设备可用。请参阅cyprusglobe suggestion。
执行命令
- chmod 755 android/gradlew
- react-native run-android