简体   繁体   中英

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. For that reason I just simply used the following commands -

npm run eject

I set up the sdk path for my Genymotion like below- Genymotion SDK path

I also set up the system variable in my environment for the Android like below- System variable for Android

Then after setting up the project and starting my android avd I wrote the following command in my terminal-

react-native run-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

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'.

    Could not resolve all files for configuration ':classpath'. Could not resolve 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 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 '. Could not GET ' 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?

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.

{
  "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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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