Building and installing the app on the device When I first came into contact with react-native, I encountered two mistakes

When I first came into contact with react-native, I encountered two mistakes

error one

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

Solution

Delete all gradle packages under C:\Users\g\.gradle\wrapper\dists\, and download again, possibly because of network speed, or other reasons that cause the package to be damaged

error two

ÎÊÌâ¶þ
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

Solution

The reason for the error is that the create-react-native-app AwesomeProject command
is mixed with react-native run-android. The solution is to delete the project and create a new one. Create the correct combination of project commands:

Combination 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

When I first came into contact with react-native, I encountered two mistakes

error one

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

Solution

Delete all gradle packages under C:\Users\g\.gradle\wrapper\dists\, and download again, possibly because of network speed, or other reasons that cause the package to be damaged

error two

ÎÊÌâ¶þ
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

Solution

The reason for the error is that the create-react-native-app AwesomeProject command
is mixed with react-native run-android. The solution is to delete the project and create a new one. Create the correct combination of project commands:

Combination 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324822844&siteId=291194637