Allow overriding dev server ip via property (#55531)

Summary:
Similiar to how a specific port can be set also allow for setting a specific ip for the dev server.

This allows for easy configuration to aid in generating [reproducible builds](https://izzyondroid.org/docs/reproducibleBuilds/).

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID] [ADDED] - Allow specifying dev server ip via gradle property

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[ANDROID] [ADDED] - Allow specifying dev server ip via gradle property

Pull Request resolved: https://github.com/facebook/react-native/pull/55531

Test Plan:
1) Add `reactNativeDevServerIp=localhost` to `gradle.properties`
2) Generate an APK
3) Analyze the APK and check that the value of the string resource type `react_native_dev_server_ip` matches the value set in `gradle.properties`.

Reviewed By: cortinico

Differential Revision: D93143296

Pulled By: CalixTang

fbshipit-source-id: d0be23e9495f0ba1a6034dc31b6e725fd94a6a02
This commit is contained in:
Alexander Martinz authored and meta-codesync[bot] committed 2026-02-13 09:55:21 -08:00
1 parent a308014d87
commit 6f54846a08
1 file changed
+2 -1
@@ -88,6 +88,7 @@ internal object AgpConfiguratorUtils {
}
fun configureDevServerLocation(project: Project) {
val devServerIp = project.properties["reactNativeDevServerIp"]?.toString() ?: getHostIpAddress()
val devServerPort =
project.properties["reactNativeDevServerPort"]?.toString() ?: DEFAULT_DEV_SERVER_PORT
@@ -100,7 +101,7 @@ internal object AgpConfiguratorUtils {
ext.defaultConfig.resValue(
"string",
"react_native_dev_server_ip",
getHostIpAddress(),
devServerIp,
)
ext.defaultConfig.resValue("integer", "react_native_dev_server_port", devServerPort)
}