简体   繁体   English

弹出npm run后如何在android模拟器上运行react native项目?

[英]How to run react native project on android emulator after ejecting npm run?

I am building one react native application. 我正在构建一个反应本机应用程序。 I want to make it regular react native app and doesn't want to run it in expo. 我想让它成为常规的本机应用程序,并且不想在EXPO中运行。 For that reason I just simply used the following commands - 因此,我只使用了以下命令-

npm run eject npm运行弹出

I set up the sdk path for my Genymotion like below- Genymotion SDK path 我像下面这样为Genymotion设置sdk路径-Genymotion SDK路径

I also set up the system variable in my environment for the Android like below- System variable for Android 我还在我的环境中为Android设置系统变量,如下所示: Android的系统变量

Then after setting up the project and starting my android avd I wrote the following command in my terminal- 然后,在设置项目并启动我的android avd之后,我在终端中写了以下命令-

react-native run-android react-native运行Android

After that I am getting the following errors- 之后,我得到以下错误-

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/getting-started.html 确保已运行Android模拟器或已连接设备,并已设置Android开发环境: https : //facebook.github.io/react-native/docs/getting-started.html

There are lots of error showing the command prompt. 有很多错误显示命令提示符。 Here are some errors in details- 这是一些细节错误-

FAILURE: Build failed with an exception. 失败:构建失败,发生异常。

  • What went wrong: A problem occurred configuring root project 'demo5'. 出了什么问题:配置根项目'demo5'时出现问题。

    Could not resolve all files for configuration ':classpath'. 无法解析配置':classpath'的所有文件。 Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2. 无法解析org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2。 Required by: project : > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 project : > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 project : > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 project : > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:sdk-common:26.0.1 project : > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:sdklib:26.0.1 > com.android.tools:repository:26.0.1 project : > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 > com.android.tools.lint:lint-checks:26.0.1 > com.android.tools.lint:lint-api:26.0.1 Could not resolve org.jetbrains.kotlin:k 所需者:项目:> com.android.tools.build:gradle:3.0.1> com.android.tools.build:gradle-core:3.0.1项目:> com.android.tools.build:gradle:3.0。 1> com.android.tools.build:gradle-core:3.0.1> com.android.tools.build:builder:3.0.1 project:> com.android.tools.build:gradle:3.0.1> com。 android.tools.build:gradle-core:3.0.1> com.android.tools.lint:lint:26.0.1 project:> com.android.tools.build:gradle:3.0.1> com.android.tools。 build:gradle-core:3.0.1> com.android.tools.build:builder:3.0.1> com.android.tools:sdk-common:26.0.1 project:> com.android.tools.build:gradle: 3.0.1> com.android.tools.build:gradle-core:3.0.1> com.android.tools.build:builder:3.0.1> com.android.tools:sdklib:26.0.1> com.android。 tools:repository:26.0.1 project:> com.android.tools.build:gradle:3.0.1> com.android.tools.build:gradle-core:3.0.1> com.android.tools.lint:lint: 26.0.1> com.android.tools.lint:lint-checks:26.0.1> com.android.tools.lint:lint-api:26.0.1无法解析org.jetbrains.kotlin:k otlin-stdlib:1.1.3-2. otlin-STDLIB:1.1.3-2。 Could not get resource ' https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.pom '. 无法获取资源' https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.pom '。 Could not GET ' https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.pom '. 无法获取' https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.pom '。 Remote host closed connection during handshake 握手期间远程主机关闭连接

Can anyone help me to fix that problem so that I can run the app on my android emulator? 谁能帮助我解决该问题,以便我可以在Android模拟器上运行该应用程序?

Looking at the package.json that you posted in your comment there is no script called android so calling npm run android isn't going to run anything. 查看您在评论中发布的package.json ,没有名为android的脚本,因此调用npm run android将不会运行任何内容。

{
  "name":"demo5",
  "version":"0.0.1",
  "private":true,
  "scripts":{
    "start":"node node_modules/react-native/local-cli/cli.js start",
    "test":"jest"
  },
  "dependencies":{
    "react":"16.6.3",
    "react-native":"0.57.8"
  },
  "devDependencies":{
    "babel-jest":"23.6.0",
    "jest":"23.6.0",
    "metro-react-native-babel-preset":"0.48.5",
    "react-test-renderer":"16.6.3"
  },
  "jest":{
    "preset":"react-native"
  }
}

Make sure that your emulator is open and running then, try the command react-native run-android 确保模拟器已打开并正在运行,然后尝试使用命令react-native run-android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM