React-native 0.21 (android) remote debugger (Chrome) cannot connect - react-native

My remote debugging (Via Chrome with React-native dev tools 0.14.8) used to work fine.
I am not sure what exactly happened in between (I upgraded to react-native 0.21, did an update to android studio, updated Linux Mint 17.3 with apt-get update/ upgrade).
But now all I see is
"Please Wait
Connecting to Remote debugger" for about 5-8 seconds on my emulator, and then I get the error (see attached image):
"Unable to connect with remote debugger"
I have tried re-installing Chrome React-native extensions. Tried rebuilding my app. Did not help.
I am not exactly sure where the problem is. May be I just need to increase a value for connection timeout.. but there does not seem to be an option like that.
Below is also my package.json (it took a couple of days to go through the 0.20 to 0.21 upgrade, due to various dependency problems).
May be there is a new settings there that I am missing, that somebody could point out.
{
"name": "ftesting",
"version": "1.0.0",
"description": "ftesting desc",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node_modules/react-native/packager/packager.sh",
"android-setup-port": "adb reverse tcp:8081 tcp:8080",
"test": "eslint ./src/js.app/my.forms",
"start": "rnws start",
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
"postinstall": "npm run clean:babelrc"
},
"repository": {
"type": "git",
"url": "xyz" },
"keywords": [
"ftesting"
],
"author": "ls",
"license": "MIT",
"engines": {
"node": ">=4",
"npm": ">=2 <4"
},
"devDependencies": {
"babel-eslint": "^6.0.0-beta.1",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"eslint": "~2.2.0",
"eslint-loader": "^1.1.1",
"eslint-plugin-react": "^4.2.0"
},
"dependencies": {
"react-native": "^0.21.0",
"#remobile/react-native-splashscreen": "^1.0.3",
"react-native-blur": "^0.7.10",
"react-native-htmlview": "^0.2.0",
"react-native-material-kit": "^0.3.0",
"react-native-material-design": "^0.3.3"
}
}

There's a github issue posted with this problem. You can follow there:
https://github.com/facebook/react-native/issues/6390

Maybe it's silly problem for someone else, if it helps, for me the problem solved when I connected the wifi (I had disconnected it :)
I realized it was a connectivity problem, when I've requested from the browser the url which react native is getting the index.bundle from (the one in config settings in device app) and found that it was reachable...
I'm using 0.25.0-rc

It is definitely working now.
Tested with 0.25.1
Look at the replies in the linked github issue.
Overall, I think the big problem was that once react-native team addressed the orginal issue that was introduced in 0.21, they changed the way you are supposed to build the application.
And if you did not change, the error was salient. So it was impossible to catch it during debug/build process.
Basically since Feb 2016, you are no longer supposed to pull react-native jar from maven repository. Instead, you need to point your gradle.build to the react-native jar from the npm-modules location
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../../node_modules/react-native/android"
}
}
}
and then
compile "com.facebook.react:react-native:+"
this combination of changes above, allowed me to link to the latest copy of the react-native jar, rather than pulling 0.20.1 from maven (and notice that 0.20.1 from maven had not been modified since feb 2016).

This is for apps created with react-native init or ejected from expo.
Start de app with:
react-native run-android
The emulator will show the red screen debugger connection error (that is why we are here in the first place).
With the emulator in focus press:
Ctrl+M
or from the shell issue:
adb shell input keyevent KEYCODE_MENU
The in app Developer Menu will appear:
Click in
Dev settings
Select the option:
Debug server host & port for device
And enter:
localhost:8081
Now we’ll make calls in port 8081 in the emulator go to the same port on the host machine.
From the shell do:
adb reverse tcp:8081 tcp:8081
Ready, just restart the app
react-native run-android

Related

Fails to build project on another local machine from repository - Failed to install the app. Make sure you have the Android development environment

So I have existing react-native project and it works and builds fine ok on one local machine.
I pushed the project to repository, but it fails to build on another machine.
So I cloned the project from repository on another machine:
did npm-install
then I tried npx react-native start but it was missing 4 choices with "open Android app", instead it only shows two (without ios and android) so i tried npx react-native run-android instead but it fails with
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.facebook.react:react-android:.
Required by:
project :app
> Could not find com.facebook.react:hermes-android:.
Required by:
project :app
If I delete node_modules (it's ignored by Git) folder and copy node_modules from the first local machine then it works fine and npx react-native start detects ios and android apps can compiles them fine.
Content of perk_sample.json:
{
"name": "nameofapp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"prop-types": "^15.8.1",
"react": "18.1.0",
"react-native": "0.70.2"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.19.0",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "0.72.3",
"react-test-renderer": "18.1.0"
},
"jest": {
"preset": "react-native"
}
}
please ask me to add any other info if needed
I upgraded RN with npx react-native upgrade based on info from https://stackoverflow.com/a/74436820/7767664
Now it's
"react": "18.2.0",
"react-native": "0.71.2"
Now npx react-native start works fine now and I can see 4 choices and it builds as well (though not from the first try after all manipulations, re-running helped, but then again tried clean build and works from the first try)
Glad I'm a native dev and it's just a temporary project :)
Also had a problem that I was excluding gradle-wrapper.jar (was added to gitignore) and react-native could not download it itself with gradle (though Android Studio doesn't need this file on the repository, it can download it itself with gradle based on url at gradle-wrapper.properties):
info Installing the app...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

SIGTRAP when starting electron on WSL2

I followed various online steps in Github forums and blogs to install VcsXsrv so that I could run an electron app through WSL for development. But I have been stuck on the following error when running yarn start:
/home/me/dev/my-electron-app-2/node_modules/electron/dist/electron exited with signal SIGTRAP
Specs:
AMD Radeon R9 380 Series
Windows 10 Pro Build 19044.1826 (3/23/21)
VcsXsrv installed (1.20.14.0)
WSL2 (latest) for Ubuntu 18.04
Dev Setup:
Node 16.15.0
Npm 8.5.5
package.json
{
"name": "myapp",
"version": "1.0",
"description": "My Desktop App",
"main": "main.js",
"scripts": {
"start": "electron .",
},
"author": "Me",
"license": "Apache-2.0",
"dependencies": {
"compromise": "^13.11.1",
"compromise-numbers": "^1.3.0",
"compromise-sentences": "^0.3.0",
"electron": "^19.0.8"
},
"devDependencies": {
"electron-packager": "^15.2.0"
}
}
Steps Tried:
Updating from Electron 15 to 19
Clearing package-lock.json
Making sure VcsXsrv was not blocked by firewall (public/private)
Updating WSL from 1 to 2
What did it I think was following this tutorial, specifically installing those missing libraries: https://www.beekeeperstudio.io/blog/building-electron-windows-ubuntu-wsl2
Incomplete list of libraries needed for electron/WSL Xserver usage:
libnss3-dev
libgdk-pixbuf2.0-dev
libgtk-3-dev
libxss-dev
libasound2
libgconf-2-4
libatk1.0-0
Related questions that were useful:
General setup: How to set up working X11 forwarding on WSL2
Similar fault: Electron not starting properly due to SIGTRAP
Another similar fault: Electron in Docker: SIGTRAP, ELIFECYCLE, errno1
WSL issue: https://github.com/microsoft/WSL/issues/6430
Another setup guide: https://gist.github.com/caseywatts/9700b402b6b51d1d6af9f0b206739770

Unable to resolve module react-native/Libraries/Components/View/ViewStylePropTypes

This is my package.json:
{
"name": "BStore",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"expo": "^32.0.5",
"native-base": "^2.11.0",
"prop-types": "^15.7.2",
"react": "16.6.3",
"react-native": "0.58.3",
"react-native-gesture-handler": "^1.0.15",
"react-native-paper": "^2.11.0",
"react-navigation": "^3.0.9",
"react-navigation-material-bottom-tabs": "^1.0.0"
},
"devDependencies": {
"babel-core": "7.0.0-bridge.0",
"babel-jest": "24.1.0",
"jest": "24.1.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
I am getting this error Unable to resolve modulereact-native/Libraries/Components/View/ViewStylePropTypes`
any ideas how can I solve this issue?
Had same issue.
As I find out expo 32.0.5 and react-native 0.58.3 are not compatible. So expo react-native fork should be used.
To install it you can use command
npm install --save react-native#https://github.com/expo/react-native/archive/sdk-32.0.1.tar.gz
You have to read the error-message carefully. I've the same issue, mine was:
Unable to resolve module
react-native/Libraries/Components/View/ViewStylePropTypes from
/APP/node_modules/react-native-render-html/src/HTMLUtils.js:
Module react-native/Libraries/Components/View/ViewStylePropTypes
does not exist in the Haste module map
So the 3rd Party Library react-native-render-html cause the error, because it try to use ViewStylePropTypes.
In case of #adrian-moisa: For you it's react-native-reanimated.
Don't know what the cause was for the ThreadOpener, he didn't post an usable error-message.
Fact is, that ViewStylePropTypes was removed up from react-native 0.58
compare:
https://github.com/facebook/react-native/tree/v0.57.8/Libraries/Components/View
https://github.com/facebook/react-native/tree/v0.58.0/Libraries/Components/View
So the solution is to figure out, which 3rd-Party Component cause the error, and look if there is an upgrade from the maintainer, or yourself have to patch it (e.g. with patch-package)
This combo works for me:
"expo": "^31.0.4",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",
I adjusted the instructions from here, with what worked for me:
Here’s how to upgrade your app to Expo SDK 32.0.6 from 31.0.0:
Close your Expo CLI server In app.json, change sdkVersion to "32.0.1"
In package.json, change these dependencies:
react-native to "https://github.com/expo/react-native/archive/sdk-32.0.1.tar.gz"
expo to "^32.0.6"
react to "16.8.6" — (this exact version)
react-navigation to "^3.9.1" (if you use it — this is also optional, you don’t have to update it to use the newest SDK. If you
choose to, make sure you read the changelog for breaking changes, and
see this upgrade guide for upgrading from v2 to v3.)
jest-expo to "^32.0.0" (if you use it)
sentry-expo to "~1.11.2" (if you use it) Delete your project’s node_modules directory and run npm install again (or use Yarn, we
love Yarn) Run expo start -c Update the Expo app on your phones from
the App Store / Google Play. expo-cli will automatically update your
apps in simulators. Make sure to check the breaking changes section
of this post! If you built a standalone app previously, remember that
you will need to create a new build in order to update the SDK
version. Run expo build:iosand/or expo build:android when you are
ready to do a new build for submission to stores. If you are planning
to submit your iOS app to the App Store, you must upgrade to Xcode 10
in order to do so.

Requiring unknown module "11" error on iOS simulator

When I run the react native project with react-native run-ios.It shows the following error on my iOS simulator.On my android simulator, it is totally ok.I have deleted node module and reinstalled.But the error is still there.I don't want to entirely delete my ios/build folder since I have manually added library dependencies in there and that third party libraries were working properly in my react native project.Can someone help me with this?
Error Message
Requiring unknown module "11".If you are sure the module is there, try
restarting Metro Bundler.You may also want to run yarn or npm install(
depending on your environment ).
package.json
{
"name": "AwwsomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-navigation": "^1.1.473",
"react-native-vector-icons": "^4.6.0"
},
"devDependencies": {
"babel-jest": "23.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "23.2.0",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
Restarting packager fixed my issue.
I fixed the issue with the instructions from the following page:
https://facebook.github.io/react-native/docs/troubleshooting#content
Basically it asks you to terminate the processes running on a specific port.
Run the following command to find the id for the process that is listening on port 8081:
$ sudo lsof -i :8081
Then run the following to terminate the process:
$ kill -9 <PID>
I just killed all node processes
killall node
🙌 and launched again
I had the same problem. Running npm install or yarn install should fix the issue.
I had the same problem while working with my react native app and expo. Same screen with 'Requiring Unknown Module 1".
This is how I fixed it:
I closed Expo
I closed the Metro bundler on my local host
I closed the packager on my terminal with Ctlr + C
I restarted with npm start
I relaunched the project on Expo.
It worked for me.
I had this issue on Android (React-Native-CLI).
Terminating the application and restarting metro server absolutely solved the issue.
yarn react-native start
Using yarn, I did the following (for Android emulation):
From root directory in your project:
cd android
./gradlew clean
cd ..
yarn start --reset-cache
yarn android
Looks like node and the application inside simulator hangs sometimes. I encountered this several times on macOS / iOS.
yarn install did not help.
restarting simulation with expo run:ios / yarn start / yarn ios did not help.
What helped was killall node and killall <your_mobile_app_name>.
npm run ios fixed for me after npm start

New react-native project can't run-ios: The following build commands failed: CompileC

I am just trying to spin up a new react-native app but no luck.
react-native init NewApp
cd NewApp
npm install
react-native run-ios
Then see the below error:
** BUILD FAILED **
The following build commands failed:
CompileC /Users/arc/Desktop/websites-dev/react-native/testing_rn/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTProfile.o Profiler/RCTProfile.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/testing_rn.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/testing_rn.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Using:
npm 4.1.2
node v7.5.0
El Capitan 10.11.6
Xcode 8.2
package.json:
{
"name": "testing_rn",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.4.2",
"react-native": "0.42.3"
},
"devDependencies": {
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2",
"react-test-renderer": "15.4.2"
},
"jest": {
"preset": "react-native"
}
}
It seems like this may be related to the build via terminal but app may still work in xcode?
Print: Entry, ":CFBundleIdentifier", Does Not Exist have tried most solutions
github issue from 25 days ago:
https://github.com/facebook/react-native/issues/12737
Some related questions:
https://github.com/facebook/react-native/issues/7308
React-native run-ios commands fails
=========================================================
UPDATE:
For me, this seemed to have something to do with 0.42.0 and above. I can run a 0.41.2 project that I install with
react-native init --version 0.41.2 example412
cd example412
npm install
react-native run-ios
And boom. It works. But this gets errors:
react-native init example_latest
cd example_latest
npm install
react-native run-ios
then above errors are back. Same errors with init version at 0.42.0:
react-native init --version 0.42.0 example420
cd example420
npm install
react-native run-ios
For me, I guess I needed to update xcode. I thought I was on 8.3 but apparently not. I also needed to update osx to 10.12.4 prior to updating my xcode. Now I'm all good and running a react-native init app at 0.42.3