I am working on a react-native application, when I run my debug build I am able to debug using the metro tool using the following commands.
npx react-native start
npx react-native run-android
Magically my emulator pops up and if I click "d" in the metro terminal it activated my debugging tools.
When I run
npx react-native run-android --variant=release
When I click "d" in the metro terminal it says
warn No apps connected. Sending "devMenu" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
info Opening developer menu...
Is there something about the release build that does not allow for the use of these debugging tools or is there something I need to do within build.gradle or some other configuation file to enable using the metro debugger.
I am new to react-native development so my apologies if my terminology is off.
Appreciate you help!
After receiving feedback from various people on and off of SO it seems that the debugger is not meant to be used in the release build.
In my circumstance there was an issue with gradle configuration involving react-native-config which was a known issue related to Progaurd which would only impact release builds.
As recommended in this post I used the javascript alert() method to debug the issue.
Related
I have an interesting scenario. It was an expo project that I converted to react-native. I don't have a react-native command (but can run npx react-native, but my understanding is to build the test APK I run yarn android which actually runs expo run:android.
However, my dev server is remote, so I'm looking to generate an APK and then use the developer menu to set the IP address of the dev server on the device, then connect to the react native server (i.e. not using Expo anymore)
How do I go about building this APK? When I use yarn android it says there are no devices connected and won't build.
Thanks!
npx react-native run-android builds an APK in ./android/app/build/outputs/apk but then fails. Just install this APK, then run it, shake the device to get the menu to pop up (or Cntrl-M for the menu on an emulator), settings, and dev server info is there (port 8081 default).
I am using android 8.1 simulator to debug my React Native (0.62) app with VS code on Win10. After firing up the app with react-native run-android, Ctrl+m brings up the dev menu:
But there is no option of Debug JS remotely in the menu. How can I bring up the option of Debug JS Remotely?
You should be able to debug a RN app in Chrome dev tools, unless you are running a production build.
If you want to use another debugger, you can set it with the REACT_DEBUGGER env. variable. Example:
REACT_DEBUGGER="node /path/to/launchDebugger.js --port 2345 --type ReactNative"
For VSCode there is this extension. There is a section explaining how to debug.
Supposedly the two ways you can start a react native android app are:
react-native run-android via command line
OR
Open your project in android studio and press Run.
The issues I am experiencing are that using option 1, i will get an error that no devices are available:
com.android.builder.testing.api.DeviceException: No connected devices!
and using option 2 results in an emulator starting and the installation of the app successfully, but the JS packager doesnt start as part of this flow.
Now sure, I can easily get around this by either
Run the packager manually before starting the app in Studio
Starting an emulator before running react-native run-android
but it seems like this is indicative of a problem somewhere
I have checked out this similar question here React Native: Android Studio doesn't automatically bundle when building but that is unrelated to whats happening to me
is there any way or framework to Running On Device from android studio to run option to launch the app. (instead of react-native run-android command)
I don't see any stuff like that from React-Native Docs.
Update: i got some info after my research. i am seeing there is a possibility to create/modify a gradle task which can run the yarn commands to launch my app. will keep posted.
I had the same problem.
Solution
Open your project in Android Studio
Start react native packager by typing react-native start (it will pop-out a terminal for js-bundling)
In android studio "Run" your App. (In case you want to use break-points "Debug-Run" your App.)
You are Done.
Just open the project on android studio and hit the play button, it should work.
I am using react native
react-native-cli: 2.0.1
react-native: 0.55.3
I was running via
react-native run-android
The screen is always loading the app (Debugger Mode)
NOTE: It was sudden issue, it was working fine till yesterday.
*PC is Restarted several time and also JS server using kill -9 PID
I've met this error before when I started to programming React Native on Ubuntu.
The reason why you got this error because your Genymotion didn't have same port with local machine.
So here is the solution:
Open the Developer Menu of mobile app on Genymotion
Choose the Debug Server port & port for device
Set the value localhost:8081
reload the app and enable the Debug. Now you can debug the app.
Cheer!
Maybe it is a problem with the app already installed in your phone.
Try running :
adb uninstall com.yourproject
This will install all of your project packages for all users on your emulator/phone
Temporary fix:
REACT_TERMINAL=<your terminal> react-native run-android
in my case with manjaro + xfce4:
REACT_TERMINAL=xfce4-terminal react-native run-android
or puts in your .bashrc:
export REACT_TERMINAL=xfce4-terminal