JS server already running react native app - javascript

I'm following the Getting Started tutorial from here: https://facebook.github.io/react-native/docs/getting-started.html. I'm able to boot up my package manager with react-native start. But running the application itself always results in a crash.
$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug...
Error occurred during initialization of VM
Unable to use shared archive.
An error has occurred while processing the shared archive file.
Unable to unmap shared space.
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/android-setup.html
What is the problem?

You already have a react native process running in the background on the same port.
Use ps -ef | grep react
and then kill the process using the process id
kill -9 pid
and then re execute the command:
react-native run-android

First of all give proper permission to your gradlew, in your root directory run following command
chmod 755 android/gradlew
After this make sure you have local.properties file in your android folder with sdk file path like
sdk.dir = /home/username/Android/Sdk/

Related

React Native, Failed to launch emulator. Reason: No emulators found as an output

I'm trying to run my react native app in emulator by using command react-native run-android but it's throwing that error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 44s
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync /Opt/Android/platform-tools/adb ENOENT
info Starting the app...
The system cannot find the path specified.
error Failed to start the app. Run CLI with --verbose flag for more details.
Error: Command failed: /Opt/Android/platform-tools/adb shell am start -n com.reactproject/com.reactproject.MainActivity
at makeError (C:\Users\Danger World\ReactProject\node_modules\execa\index.js:174:9)
I already setup my android studio and sdk manager, avd manager like it's shown in doc also I already set path but it's still showing that error, anyone know why? Can anyone help please?
You can fix it by using the command :
react-native doctor
This command shows all issues that need to be fixed.
Press f to fix the issues and don't forget to restart your windows
And after then open the emulator before running your project.
Once emulator opened,
run command:
react-native run-android
After fixed:
Don't forget to give me an upvote if that's work.
In My Case, I have to re-run the command in the same terminal where you are trying to run npx react-native run-android
Step 1. paste the source command first
source ~/.bash_profile OR source ~/.bashrc
Step 2. RUN Next command
npx react-native run-android
set your AVD manager path and JDK path like this , also you have to add Android Home path

Meteor server crashes very frequently without any error

I am working with the Meteor application and I deployed the same over EC2 instance. It was working fine till a few days back.
But now the server process kill automatically without any error log or
console
I tried to get the error but unfortunately, as there are not any logs I am unable to find out why the server is crashing again and again.
I have a medium EC2 machine on which the application is running.
I am using nohup for running the application in the background.
Below is the command I used to start the server:-
nohup meteor --settings SETTINGS-PRODUCTION.JSON &
I am wondering to know about server crashes due to nohup or some other reason is there.
Please let me know how we can console uncaught exception in the meteor-like we do in express.
What should I use to auto restart the server if the process is killed
by any error or exception?
Any help would be much appreciated!
Thanks
Using nohup is quite a low-tech solution. Things like Phusion Passenger, PM2, or forever do a better job.
Also your docker container can be configured to automatically restart the process.
Even better is a tool called Meteor Up, which makes it really simple to deploy Meteor apps to EC2.
EASILY DEPLOY YOUR APP Meteor Up is a production quality Meteor app
deployment tool.
Install with one command:
$ npm install --global mup
http://meteor-up.com/

Service Worker not working with create-react-app

I'm using create-react-app for generating a react.js project. It automatically implements a service-worker for progressive web app funtionality if a production build was made by using the command npm run build.
Two weeks ago everything worked fine and I was able to cache all files with the generated service-worker. But since today I always get errors:
On Chrome: Uncaught (in promise) Error: Request for http://localhost:5000/index.html?_sw-precache=aee80fca0f83208cc4d82ae2ccfda3c1 returned a response with status 301 at service-worker.js:1.
On Firefox: Service worker event waitUntil() was passed a promise that rejected with 'TypeError: NetworkError when attempting to fetch resource.'.
I have absolutely not idea why the error occurs.
Even if I create a new app and don't touch any of the generated files, the error shows up in the browsers console.
Steps to reproduce:
npx create-react-app my-app
cd my-app
npm run build
serve -s build
open app in browser
I tested it on two separate machines but get the same result. Any help is very appreciated.
Edit:
Console output after running npm run build:
C:PATH-TO-PROJECT>npm run build
> frontend#0.1.0 build C:\xampp\htdocs\gitlab\BA\App-PWA-progetraenke.app\frontend
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
164.04 KB build\static\js\main.d2519277.js
781 B build\static\css\main.77261875.css
The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:
"homepage" : "http://myname.github.io/myapp",
The build folder is ready to be deployed.
You may serve it with a static server:
serve -s build
Find out more about deployment here:
https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment
I had the same issue with a VueJS app I created by using the PWA template of Vue. What did the trick for me was updating to the latest version of vue-cli and serve.
Updating to the latest serve version (8.1.4) probably solved my problem.

error path sdk react native linux

I have installed some needed like: nodejs, python2, android studio, but when running react, error, possibly wrong path, but I check for the path I think is correct, please help
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug...
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
at com.android.build.gradle.internal.SdkHandler.getAndCheckSdkFolder(SdkHandler.java:102)
FAILURE: Build failed with an exception.
* Where:
Build file '/home/rojib/Documents/react/lat3/React-Native-Sample/android/app/build.gradle' line: 104
* What went wrong:
A problem occurred evaluating project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 27.013 secs
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/android-setup.html
SDK location on android studio : /home/rojib/Android/Sdk, Is there something wrong ?
Try this
enter this line to your package.json file in scripts
"android": "ANDROID_HOME='Your android SDK Location' node node_modules/react-native/local-cli/cli.js run-android",
and after enter this line open terminal and run this
npm run android
hope it'll work for you...

SDK error in React native

i am new to react native and an trying to run the project on emmulator "react-native run-android" . iam getting the error.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory 'D:\ReactNativeLearning\zupportdeskchat\ZDReactNative\zupportdeskapp\android\"D:\Android\sdk"' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.253 secs
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/android-setup.html
My Sdk Folder is in
sdk.dir ="D:/Android/sdk"
I set it up in local.properties.
Can someone help me to fix this tnx.
If you are working on windows system then path should be:
sdk.dir=D\:\\Projects\\Android\\sdk
Clear build cache and npm cache then try to make build.
Also check, your device is connected or not.
You are getting this error because you haven't connected a device or opened the emulator. So first connect the device to the machine and try react-native run-android or run the emulator and enter react-native run-android

Categories