2
votes

I am starting to code in ReactXP, and I need to get React-Native to work on Android device, but I am unable to test it, because error occured at the end of command react-native run-android. A also have my phone NExus 5X connected properly and I can see it through adb devices.

I think this happens, when command react-native run-android is running for 2 times and more, because when i used it first in my project, everything was ok, when I changed text in some component and ran command again, everything went wrong.

Here is a log at the end of output

Installing APK 'app-debug.apk' on 'Nexus 5X - 8.1.0' for app:debug
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 11.161 secs
Running sdk.dir=C:/Users/pc123/AppData/Local/Android/Sdk/platform-tools/adb -s 020b60af2344b558 reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync sdk.dir=C:/Users/pc123/AppData/Local/Android/Sdk/platform-tools/adb ENOENT
Starting the app on 020b60af2344b558
(sdk.dir=C:/Users/pc123/AppData/Local/Android/Sdk/platform-tools/adb -s 020b60af2344b558 shell am start -n com.rxptodolist/com.rxptodolist.MainActivity)...

SDK is located correctly, i had some errors earlier, but i already solved them, i also trid following steps from Stack Overflow posts, but still no luck - for example this React Native adb reverse ENOENT or Could not run adb reverse (React-Native)

OS Windows 10

2
It shouldn't matter, doesnt it loads the apk on your device ? Also uninstall the existing apk from your device before running this cmd.Fawaz

2 Answers

4
votes

Make sure your port 8081 is clean and ready to use.Check whether other services are listening to that port.try this react-native start --port=8081

0
votes

Change the default port to 8088(or whatever port you like: just make sure it is not reserved like the port number 80 for HTTP) on yourApp\node_modules\react-native\local-cli\server\server.js. It will look something like this.

....
module.exports = {
  name: 'start',
  func: server,
  description: 'starts the webserver',
  options: [{
    command: '--port [number]',
    default: process.env.RCT_METRO_PORT || 8088,
    parse: (val: string) => Number(val),
  },
....