Buid successful but Failed to connect to development server using adb reverse - react-native

My machine is: Ubuntu 18.04, react
First I open Android studio and turn on Virtual device:
Then I run command In two tabs Terminal:
tabs 1: react-native start
tabs 2: react-native run-android
And It show that:
BUILD SUCCESSFUL in 3s 27 actionable tasks: 2 executed, 25 up-to-date
/bin/sh: 1: adb: not found info Connecting to the development
server... warn Failed to connect to development server using "adb
reverse": spawnSync adb ENOENT info Starting the app...
BUT when I raun command: source $HOME/.bash_profile
and then I run: react-native run-android
It's ok
Why?

I've encountered the same problem on my Windows machine as well as my Ubuntu Linux machine. The fix that I found for both was to switch to version 10 of NodeJS. (I believe the problem is that Metro server doesn't seem to like v8, v12, or v13 of NodeJS, but v10 seems to work great)

Related

Getting Building iOS bundle error when trying to build an android app - expo -react-native

I was able to build app using expo build:android previously. However, after upgrading to latest expo version I get following error:
connect ECONNREFUSED 127.0.0.1:19001
Set EXPO_DEBUG=true in your env to view the stack trace.
I also see the following lines in the log:
Publishing to channel 'default'...
Building iOS bundle
I don't added ios to my app.json, I only need to build an android apk. To do that I use expo build:android -t app-bundle
I also removed package-lock.json and node_modules and run npm install, but I get the same error.
I run expo start on another cmd and then run expo build:android -t app-bundle still get same error
Also when I clear expo cache, see the following log:
Restarting Metro Bundler...
Starting Metro Bundler on port 19001.
Couldn't adb reverse: adb.exe: error: Invalid source port: 'undefined'
I had faced same issue myself and found the solution. Expo is looking for localhost:19001 which is not running. Just follow following steps and it should work as expected:
Run expo start no terminal and once it opens up the
browser where you will find this line written Starting Metro
Bundler on port 19001.
Now open another terminal instance and run expo build:android.

Failed to load bundle - Could not connect to development server

I've been looking for a solution to this issue for a day now but couldn't fix it.
I have not used react native for a month when everything was working fine.
Now, if I try to run an existing project that used to work (react native 0.59.5) or a brand new project (react native 0.59.9) with the iOS simulator on my mac, I get the error:
Failed to load bundle - Could not connect to development server
Any idea how I can fix this?
Ok found the issue. Was thinking it might be watchman related issue and wanted to use the command brew reinstall watchmanto reinstall it. By running this command, I found an error
Error: Xcode alone is not sufficient on Mojave. Install the Command Line Tools: xcode-select --install
Looks like the command line tools for xCode was not available anymore.
I launched the command xcode-select --install and then reinstalled watchman just in case. It is now working!
Couldn't connect to development server error
This error is received when the metro bundler isn't running in port 8081. To start the bundler, from project folder run:
npm start
Now, try reloading your app (ctrl + R for iOS / r+r for Android).
Also, check your terminal in case the project failed initial build due to some error.

wrapItem(...).trimStart in Expo and React native

Today I create a new project with create-react-native-app and after installing dependencies CRNA says to start your project with expo start, after running this command all thing seems good and a chrome open page localhost:19002 but after a minute this page is stoped and in the console it says :
[12:26:47] Starting project at D:\Try\eleventh
[12:27:13] Warning: Problem validating app.json: Unable to perform cache
refresh for C:\Users\Mohammad\AppData\Local\Expo\schema-30.0.0.json:
Error: connect ETIMEDOUT 35.202.142.166:443.
[12:27:39] Starting Metro Bundler on port 19001.
[12:27:39] Metro Bundler ready.
[12:27:40] Opening on Android device
[12:27:40] Successfully ran `adb reverse`. Localhost URLs should work on
the connected Android device.
[12:27:44] Tunnel ready.
[12:27:44] Expo DevTools is running at http://localhost:19002
[12:27:44] Opening DevTools in the browser... (press shift-d to disable)
exp://192.168.89.2:19000
To run the app with live reloading, choose one of:
[12:27:44] wrapItem(...).trimStart is not a function
[12:27:44] Set EXPO_DEBUG=true in your env to view the stack trace.
as you see it says :
wrapItem(...).trimStart is not a function
and this is some information may be useful :
create-react-native-app version: 2.0.2
node version: v8.11.3
expo version: 2.2.0
npm version: 6.4.0
yarn version:1.10.1
Try using a later version of node. I ran into this issue as well using node version 8. Bumping it with nvm to node 12 worked.

Failed completely to run the react native app on real device

I have tried most of solutions on the stackoverflow and github issues related to react native but all in vain... for almost 2 weeks.
Environment
react-native-cli: 2.0.1
react-native: 0.56.0
Window 10 Pro
Using android device 5.1(lollilop)
well the app ran successful in expo client but i need to run the native code.
First error: Unable to load script from assets index.android.bundle on windows
so i was able to run command below and the error disappeared on the phone client
react-native run-android && adb reverse tcp:8081 tcp:8081
But this error has persisted on the package server console
Installing APK 'app-debug.apk' on 'BALR_X7 - 5.1' for app:debug
Installed on 1 device.
BUILD SUCCESSFUL
Running C:\Users\goldsoft25\AppData\Local\Android\Sdk;C:\Users\goldsoft25\AppDat a\Local\Android\Sdk\platform-tools/platform-tools/adb -s 7DM7R4KJ99999999 revers e tcp:8081 tcp:8081
Could not run adb reverse: spawnSync C:\Users\goldsoft25\AppData\Local\Android\S dk;C:\Users\goldsoft25\AppData\Local\Android\Sdk\platform-tools/platform-tools/a db ENOENT
Starting the app on 7DM7R4KJ99999999 (C:\Users\goldsoft25\AppData\Local\Android\ Sdk;C:\Users\goldsoft25\AppData\Local\Android\Sdk\platform-tools/platform-tools/ adb -s 7DM7R4KJ99999999 shell am start -n com.awesomeproject/com.awesomeproject. MainActivity)...
2nd error
development server return error response code --> 500 on the android device
Your help is appreciated
I ensure that i downloaded all the needed API android sdk build tools in my case API 28.0.3 and API 28...
then i run the command below.. pay attention to the location of the android sdk tools
goldsoft25#GOLDSOFTX MINGW64 ~/AppData/Local/Android/Sdk/platform-tools
$ adb devices
then later i run the command below in the same command line as below
adb reverse tcp:8081 tcp:8081
Then later i was able to run react-native run-android and it worked perfectly

Could not connect to development server on android emulator and on real device

When I run "react-native run-android",it gives me error:"could not connect to development server...".-- The red screen
OS: Windows 7
node version:8.2.1
npm version:4.1.2
react-native version:0.47.1
react-native-cli version:2.0.1
android device and emulator version: 5.1.1
i followed following command:
react-native init ProjectName
cd ProjectName
react-native run-android
And this makes the package server run automatically.
But I am not able to access the package server from browser on the machine and the mobile.
My android device connected to computer has debugging enabled i checked it using adb devices command.
Usb debug is on.
I tried running the project on real device and on emulator. On Both I got error: "Unable to load script from assets 'index.android.bundle' Make sure your bundle is packaged correctly or you're running a package server'.
reloading i get the error: "Could not connect to development server."
Then i set the host and port number on development setting on both and got the error "Could not connect to development server."
enter image description here
So how to fix the red error screen issue?Any suggestion is appreciated!
Try to open this link in browser. It will automatically bundle the assets.
http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false
You development server should be running while running this command.