ReactNative问题随记1 Exception in thread "main" java.lang.RuntimeException: gradle-2.14.1-all.zip
ReactNative问题随记
想运行在真机上,在运行命令react-native run-android遇到错误如下:
Scanning 559 folders for symlinks in D:\AppData\Project\android\AwesomeProject\node_modules (46ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: C:\Users\lipp\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv\gradle-2.14.1-all.zip
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:61)
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
截图如下:
去路径上去找发现缺少文件,首次运行命令react-native run-android 会下载gradle编译器,虽然设置了但一直失败
解决方案:
1.直接去下:http://services.gradle.org/distributions/ 找到文件对应版本的文件 gradle-2.14.1-all.zip 下载
打不开的可以去我网盘上下载:https://pan.baidu.com/s/1nvealoX (gradle-2.14.1-all.zip)
下载后放到C:\Users\lipp\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv 下,然后右键该文件属性,看是否被锁定,如果锁定点击解除锁定
注意文件路径一般是:C:\Users\{你的账号}\.gradle\wrapper\dists\gradle-2.14.1-all\{随机文件夹}
出处:http://www.cnblogs.com/lipanpan/
本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。