react-native not detected my physical device - reactjs

adb devices detect my physical phone but react-native run-android command open my emulator..
and whenever i put this command npx react-native run-android --deviceId=97e2bc510706 it shows error no emulator or android device connected I WILL GET THIS ERROR

if you have android studio , open your project's android folder in android studio and run in your physical device and in vs code run command npx react-native start and if you are using mobile hotspot then open your app and shake your device or long press minimize button , go to setting and in port add your ip (for example : ,196.168.0.1:8081) after ip put your port number.
hope it will work ...!

Always remember sdk path not contain any space in my case my username of computer is shrivastava ji so there is space in my username so remove space in your username or file name or change the sdk path where path have no space

Related

can we run react native cli app on physical device without Android studio

In the documentation of react native cli there is processe to run react native cli app directly on physical device but I am confused that do we need Android studio to run my physical device as emulator or I can directly run my physical phone as emulator by connecting through usb debugging and typing the command given there
https://reactnative.dev/docs/running-on-device
You need to connect your phone via USB and turn on debugging mode.
You can check device connectivity via running the ADB command.
adb devices
if you see your device in the console then just simply run your application via
react-native-run-android

React Native 0.60 connection to development server

(I'm almost a newbie in React Native development) today I have started a new project in React Native 0.60 (react-native init MyApp).
After that I typed : react-native run-android to check if everything worked.
After the bundle process is finished
I can finally get my welcome screen in my connected devices
But, if I try to reload the app from my devices I get this error:
How could I address this error ?
EDIT: Thank you for your answers, anyway, I have tried all solutions you suggest but I still get the same problem. I also noticed that when i run react-native run-android Metro Bundler (open in a new cli window) seems to start but it suddenly disappear. I think the problem could be with the message 'Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0'
react-native run-android not working in new react-native version
0.60
now you can use
react-native start
OR
npm start
both command is work
Please use the following two commands and then can start the react native again.
- adb reverse tcp:8081 tcp:8081
- killall node
Then you can run the following the command.
react-native start
Now you can run your application again.
Have a good day.
You need to connect your phone to the server, follow the below steps:
[For detailed help follow this https://facebook.github.io/react-native/docs/running-on-device]
1. Open the developer menu on phone.
2. Open 'Debug server host & port for device'.
3. Type in your machine's IP address and the port of the local dev server (eg. 10.0.1.1:8081). If you have connected over wifi then this will be your computers ip address. (If you are running in your computer I think instead of ip address it would be 'localhost:8081')
4. Go back to the Dev menu and select reload.
Hope it would help.
You need to run adb reverse in the Android Studio terminal so your device can connect to the server. Open Android Studio and click on the terminal button at the bottom. In the terminal, and with your device connected to your computer, enter the command adb devices. This will list the name of the connected Android device. Copy that name. Then enter this command adb -s <device name> reverse tcp:8081 tcp:8081. When you run that command replace <device name> with the name of your device you copied from the other command.
Here is a link to an explanation in the React Native documentation

How do you debug react-native when it is running on device?

How do you debug react-native when it is running on device ?
Figured our React Native debugging for Android. Steps to for someone struggling with this -
Launch your RN App
Shake device
Select "Dev Settings"
Select "Debug server host & port for device" Put in your system's IP address.
Shake device
Select "Debug JS remotely"
Chrome will open a new tab with the address "http://localhost:8081/debugger-ui"
If this doesn't happen, check your port and open a new tab and enter the above address with your port number.
Open #Chrome DevTools (Cmd+Alt+I on #MacOSX)
Select the Console Tab
Shake Device
Select "Reload"
View all your console logs or use "debugger;" in your JS for breakpoint debugging.
You have two options:
Debug remotely
iOS: Cmd + ctrl + z to open menu and select "Debug remotely"
Android: Cmd + M to open menu and select "Debug remotely"
Or run one of these commands:
react-native log-ios
react-native log-android
There are little hack in here for IOS.
In XCode open AppDelegate.m from project folder, comment the line with jsCodeLocation declaration and add near it something like this:
jsCodeLocation = [NSURL URLWithString:#"http://%YOUR_PC_IP%:8081/index.ios.bundle?platform=ios&dev=true"];
, where %YOUR_PC_IP% is IP of your dev machine on local net.
Then open project named RCTWebSocket wich located in Libraries folder and then open from this project file RCTWebSocketProjectExecutor.m. Next, comment the line with host declaration, then add near it something like that:
host = #"%YOUR_PC_IP%";
Almost done. Run app on your device with XCode and make sure that your IPhone can see your develop machin via internet.
After it launches make sure that node server is running (command "react-native -- --start" in root project folder) and open via chrome this page: http://localhost:8081/debugger-ui . Plus, option Debug JS Remotely must be enabled in your app on your IPhone. (Shake action, then tap in opened menu Debug JS Remotely, that is it.)
Now open dev console and have happy debugging.
2 options exist:
Remote debug: this would go over network, so it can be laggy.
Run app on device (install it whilst its plugged in)
Shake device (Android devices need to be vigorously shaken)
Press settings on the dev menu, and under Debugging, press Debug server host and port for device
Enter your debug server's IP address and port (usually 8081 unless you changed your settings of the debug server), e.g. 255.255.255.255:8081. Your ip address is the local IP address that your computer has. Ensure the device is on the same network. For mac users, open System Preferences → Network → Wifi → Under Status: connected, there is an IP address, use that.
You can unplug the device
Ensure debug mode is on (Shake device vigorously again, press Debug)
Wired debug: relatively better for slow connections
Install app on phone
If android, set up port forwarding with adb reverse tcp:8081 tcp:8081 and if iOS, follow the steps from RN docs)
Enable debug on device
If you are working on Visual Studio Code then you can install React Native Tools extension (provided by Microsoft) and debug your app like any other IDE.
Read all steps in detail in my this answer.

Could not get BatchedBridge, make sure your bundle is packaged correctly happened on Android v4.4.2

I compiled react-native on Android v4.4.2 but the problems arised:
I tried to follow this solution, but I did not how to run on Command Prompt Windows 10:
$> cd myproject
$> react-native start > /dev/null 2>&1 &
$> curl "http://localhost:8081/index.android.bundle?platform=android" -o
> "android/app/src/main/assets/index.android.bundle
$> (cd android/ && ./gradlew assembleDebug)
I tried to compile the same way on Android V6.0. Then there was no problem at all.
How to make android V4.4.2 also can be use like Android v6.0 for my first react-native
project development?
That error means your React Native app can't fetch your JS files from your localhost. You'd usually just run react-native start to serve the JS files from your packager, but Android 4.4.x cannot connect to your localhost with the default adb reverse method.
The way I run on Android 4.4.x is to manually set the device to connect to my machine via Wi-Fi (Official guide here!).
Access the React Native dev menu by shaking your device or pressing the hardware menu button (can be done with Ctrl+M or Cmd+M in a simulator, IIRC)
Go to Dev Settings
Under the Debugging section, tap "Debug server host & port for device"
Enter your machine's IP address, as well as the port through which the React Native packager is serving, e.g. "10.0.0.25:8081" (make sure your device and your machine are on the same network!)
Reload through the dev menu again (or by pressing Ctrl+R or Cmd+R in a simulator, I think)
Try running this command
adb reverse tcp:8081 tcp:8081

Error while installing app in android emulator in win8

As I was trying to install the app in my emulator through command prompt, it shows--
"error- more than one device and emulator."
I've 4 emulator but only 1 was online while I was installing the app.
I use this command (without quotes)
"adb install .apk"
Need help!!
close emulator, close adb. open and reconnect, you can use
adb devices
to see connected devices.

Resources