Building and installing the app on the device 初次接触到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.<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

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

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

解决办法

删掉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.

½â¾ö£º

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

解决方式

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

组合1

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

   
   
  • 1
  • 2
  • 3
  • 4

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值