Failed to fully start Android device Emulator on a windows 11 machine to run a react native application - react-native

I am building a react-native application and I have been testing the application on an android device simulator. However after running the npm run eject command to stop using the expo-cli; I have failed to run the project/app in my android emulator anymore.
Initially I was opening the android emulator within VSCode but after it failed I tried to open the android emulator in command propmt directly; outside the code editor. Below is the output I received.
INFO | Android emulator version 31.2.7.0 (build_id 8135630) (CL:N/A)
INFO | added library vulkan-1.dll
INFO | configAndStartRenderer: setting vsync to 60 hz
ERROR | Failed to open /qemu.conf, err: 2
WHPX on Windows 10.0.22000 detected.
Windows Hypervisor Platform accelerator is operational
INFO | Started GRPC server at 127.0.0.1:8554, security: Local
INFO | Advertising in: C:\Users\Were\AppData\Local\Temp\avd\running\pid_8104.ini
C:\Users\Were\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: WHPX: Unexpected VP exit code 4
INFO | Shutting down gRPC endpoint
INFO | Shutting down gRPC endpoint
I need someone to help me make sense of the statement/error log so I can be able to run my app in the android emulator again.
[EDIT]
This is the error log i received within VisualStudio Code before trying to open the emulator in command prompt
› Press ? │ show all commands
› Opening on Android...
› Opening emulator My_Pixel_Emulator
Couldn't start project on Android: The emulator (My_Pixel_Emulator) quit before it finished opening. You can try starting the emulator manually from the terminal with: C:\Users\Were\AppData\Local\Android\Sdk/emulator/emulator #My_Pixel_Emulator
› Press ? │ show all commands
C:\Users\Were\Desktop\Demo\DoneWithIt\node_modules\metro-hermes-compiler\src\emhermesc.js:81
throw ex;
^
RuntimeError: abort(Error: could not connect to TCP port 5554: cannot connect to 127.0.0.1:5554: No connection could be made because the target machine actively refused it. (10061)). Build with -s ASSERTIONS=1 for more info.
at process.abort (C:\Users\Were\Desktop\Demo\DoneWithIt\node_modules\metro-hermes-compiler\src\emhermesc.js:796:13)
at process.emit (events.js:315:20)
at process.emit (C:\Users\Were\AppData\Roaming\npm\node_modules\expo-cli\node_modules\source-map-support\source-map-support.js:439:21)
at processPromiseRejections (internal/process/promises.js:245:33)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Related

React native device 'adb' not found

I am trying to open my react native app on the android studio device emulator but I am facing an error :
Couldn't start a project on Android: Error running adb: spawn emulator ENOENT
Error running adb: spawn emulator ENOENT
Also, my emulator is in running condition. how to fix this
make sure code is working on web, then restart AVD. by closing it completely. mine is working now. but after some time whenever there is any error in code it crashes again and repeating the process makes it working. also before starting in AVD please close web testing.

React native emulator failed to start in windows10

Does anyone knows how to fix this issue?
This is the exact command and result in windows 10.
react-native run-android
> info Running jetifier to migrate libraries to AndroidX. You can
> disable it using "--no-jetifier" flag. Jetifier found 864 file(s) to
> forward-jetify. Using 4 workers... info Starting JS server... 'adb' is
> not recognized as an internal or external command, operable program or
> batch file. info Launching emulator... error Failed to launch
> emulator. Reason: No emulators found as an output of `emulator
> -list-avds`. warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
This is the actual screen shot.

Buid successful but Failed to connect to development server using adb reverse

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)

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.

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.