转自:http://www.jb51.cc/article/p-onuasaoe-pm.html
1.问题
D:\rnworkspace\Hello>React-native run-Android @H_404_8@ JS server already running. @H_404_8@ Building and installing the app on the device (cd android && gradlew.bat install @H_404_8@ Debug)… @H_404_8@ Downloading https://services.gradle.org/distributions/gradle-2.4-all.zip @H_404_8@ …………………………………………………………………….. @H_404_8@ …………………………….. @H_404_8@ Unzipping C:\Users\ltn.gradle\wrapper\dists\gradle-2.4-all\6r4uqcc6ovnq6ac6s0tx @H_404_8@ zcpc0\gradle-2.4-all.zip to C:\Users\ltn.gradle\wrapper\dists\gradle-2.4-all\6r @H_404_8@ 4uqcc6ovnq6ac6s0txzcpc0 @H_404_8@ 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:215) at java.util.zip.ZipFile.<init>(ZipFile.java:145) at java.util.zip.ZipFile.<init>(ZipFile.java:159) 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(ExclusiveFileAcc
essManager.java:65) @H_404_8@ at org.gradle.wrapper.Install.createDist(Install.java:46) @H_404_8@ at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126) @H_404_8@ at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) @H_404_8@ Could not install the app on the device,read the error above for details. @H_404_8@ Make sure you have an Android emulator running or a device connected and have @H_404_8@ set up your Android development environment: @H_404_8@ https://facebook.github.io/react-native/docs/android-setup.html
(node:5276) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
tion id: 2): TypeError: Cannot read property ‘message’ of undefined
2.解决
这问题原因是在你创建工程gradle-2.4-all包下载不完全或者没有下载所致。 @H_404_8@ 1.你可以重新创建工程。 @H_404_8@ 2.下载http://pan.baidu.com/s/1b2Vb2Y包,放在C:\Users\xxxx.gradle\wrapper\dists\gradle-2.4-all下,重新运行