Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shirakaba/dd3c56df1a5978fee9168d2c131edcd7 to your computer and use it in GitHub Desktop.
Save shirakaba/dd3c56df1a5978fee9168d2c131edcd7 to your computer and use it in GitHub Desktop.
Making React Native Android devices auto-connect to Metro without adb reverse

From my original discussion on BlueSky here:

In React Native, physical iOS devices can connect to Metro automatically because react-native-xcode.sh writes a file into $DEST/ip.txt for reading at runtime.

On Android physical devices, however, we have to do adb -s <device_name> reverse tcp:8081 tcp:8081.

Can't Android use the iOS approach?

Nicola Corti recommended hooking into configureDevPorts() in the react-native-gradle-plugin.

I searched for usages of react_native_dev_server_port and found getServerIpAddress() in the React Native Android runtime as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment