初次接触到react-native,遇到的两个失误

初次接触到react-native,遇到的两个失误

错误一

D:\node\AwesomeProject>react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Unzipping C:\Users\g\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv\gradle-2.14.1-all.zip to C:\Users\g\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv
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.(ZipFile.java:219)
        at java.util.zip.ZipFile.(ZipFile.java:149)
        at java.util.zip.ZipFile.(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

ɾ³ýgradle-2.14.1-all°ü£¬ÖØÐÂÏÂÔØ¡£

解决办法

删掉C:\Users\g\.gradle\wrapper\dists\下的所有gradle包,重新下载,可能输网速的原因,或者其它原因导致包被破坏

错误二

ÎÊÌâ¶þ
Loading dependency graph, done.
error: bundling: NotFoundError: Cannot find entry file index.android.js in any of the roots: ["D:\\node\\AwesomeProject\\node_modules\\react-native\\packager"]
    at DependencyGraph._getAbsolutePath (D:/node/AwesomeProject/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:280:11)
    at DependencyGraph.getDependencies (D:/node/AwesomeProject/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:218:26)
    at Resolver.getDependencies (D:/node/AwesomeProject/node_modules/react-native/packager/src/Resolver/index.js:107:27)
    at D:/node/AwesomeProject/node_modules/react-native/packager/src/Bundler/index.js:591:37
    at next (native)
    at step (D:\node\AwesomeProject\node_modules\react-native\packager\src\Bundler\index.js:12:445)
    at D:\node\AwesomeProject\node_modules\react-native\packager\src\Bundler\index.js:12:605
    at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.android.js`  0.0% (0/1), failed.

½â¾ö£º

解决方式

错误原因是create-react-native-app AwesomeProject命令和react-native
run-android混用导致的,解决办法是删掉工程,新建一个工程。创建工程命令正确的组合方式:

组合1

  create-react-native-app AwesomeProject
  cd AwesomeProject
  npm start

组合2
react-native init AwesomeProject
cd AwesomeProject
react-native run-android

你可能感兴趣的:(前端,环境部署,总结)