Debug App in Real Android Device using USB Connection
After developing the React Native App it is always a good idea to test it on the real device because many times an app behaves differently in the emulator then the real device. This post will cover How to Run React Native App On Real Device in Windows/Linux/Mac.
Enable Debugging Over USB option
First of all, to run a debug app in your Android device you need to Enable Debugging over USB. To do this we have to do the following steps:
Find for the Build number or MIUI version and click it multiple time, until it shows you are a developer now
You will find a Developer Option direct in settings or in Additional Settings
After that Enable Developer Option and USB debugging
Attach your Real Device
After doing this you have to attach your Real Device with the computer using a USB cable and run the following command on terminal.
adb devices
Run the App
Now run your app using
npx react-native run-android
Known Issue
If you get a “bridge configuration isn’t available” error. Then use below command to solve
adb -s <device name> tcp:8081 tcp:8081
Here you have to replace <device name>
with your device name. You got the name using adb devices
.
Now re-run the app using
npx react-native run-android
Screenshot of the app running in the real device
Developer Menu
If you are doing some changes and want to see in your device you have to enable the Hot/Live Reloading which can be done form the Developer Menu
. To open the Developer Menu in Real Device you just need to shake the device and it will open the Developer Menu popup for you.
This is how you can run the React Native App on Real Device. In some cases, it becomes too hectic to manage cable all the time so there is another solution to Connect Your device with the development server using Wi-Fi.
This is how you can run React Native App on Real Device. If you have anything to share please comment below or contact us here.
Hope you liked it 🙂
I like your approch to teach
The command for correcting networking on the physical device should instead be:
adb -s reverse tcp:8081 tcp:8081
How do I shake an Android device within the Android emulator to bring up the dev menu to debug my React Native app
Use ctrl+d in case of emulator
I have two Mobile connected with PC. How I can run App on two device at the same time.
why we have entered IP address 10.0.2.2? it is fixed or can we changed
Not Sure. Any one else can help?
Is android studio needed? Or only installing adb is required? Tell me the steps for doing adb configuration.
It is better to install Android Studio as it will help you to manage all add and SDK which you will need while compilation.
I am trying to run in real devices but open automatically de emulator.
To run in a real devices the phone and computer need to be in same wifi?
Yes, It needs to be in the same wifi
Hi Team,
adb : The term ‘adb’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
set PATH : C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools
build error.
* What went wrong:
Execution failed for task ‘:app:installDebug’.
> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl337623935.tmp/base.apk (at Binary XML file line #131): does not have valid android:name
please help me
Do invalidate cache and restart in android studio.
Or ,You can also Try clearing cache in ./android folder using command ./gradlew clean, then repeat the above processes.
Still facing the issue? I think that is related Android configuration.