Skip to content

Conversation

@cortinico
Copy link
Contributor

Summary:
This removes the need to specify 2 Manifests for apps and we can just use the main manifes to toggle if usesCleartextTraffic should be enabled or not.

This will have to be replicated in the template repository.

Changelog:
[Android] [Added] - Add support to specify a single Manifest rather than 2 (main/debug) by using the usesCleartextTraffic manifest placeholder which is autoconfigured by RNGP.

Differential Revision: D78425139

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 16, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78425139

…facebook#52620)

Summary:
This creates a `debugOptimized` build type for React Native Android, meaning that we can run C++ optimization on the debug build, while still having the debugger enabled. This is aimed at improving the developer experience for folks developing on low-end devices or emulators.

Users that intend to debug can still use the `debug` variant where the full debug symbols are shipped.

## Changelog:

[ANDROID] [ADDED] - Create a debugOptimized buildType for Android

Pull Request resolved: facebook#52620

Test Plan:
Tested locally with RNTester by doing:

```
./gradlew installDebugOptimized
```

This is the output of the 3 generated .aar. The size difference is a proof that we're correctly stripping out the C++ debug symbols:

<img width="193" height="54" alt="Screenshot 2025-07-15 at 17 49 50" src="https://github.com/user-attachments/assets/584a0e8d-2d17-40d4-ac29-da09049d6554" />
<img width="235" height="51" alt="Screenshot 2025-07-15 at 17 49 39" src="https://github.com/user-attachments/assets/eda8f9e7-3509-4334-8c16-990e55caa04d" />
<img width="184" height="52" alt="Screenshot 2025-07-15 at 17 49 32" src="https://github.com/user-attachments/assets/a5c94385-bc00-4484-b43e-088ee039827f" />

Differential Revision: D78351347

Reviewed By: cipolleschi

Pulled By: cipolleschi
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78425139

cortinico added a commit to cortinico/react-native that referenced this pull request Jul 18, 2025
…er (facebook#52647)

Summary:
Pull Request resolved: facebook#52647

This removes the need to specify 2 Manifests for apps and we can just use the `main` manifes to toggle if `usesCleartextTraffic` should be enabled or not.

This will have to be replicated in the template repository.

Changelog:
[Android] [Added] - Add support to specify a single Manifest rather than 2 (main/debug) by using the `usesCleartextTraffic` manifest placeholder which is autoconfigured by RNGP.

Reviewed By: cipolleschi

Differential Revision: D78425139
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78425139

cortinico added a commit to cortinico/react-native that referenced this pull request Jul 18, 2025
…er (facebook#52647)

Summary:
Pull Request resolved: facebook#52647

This removes the need to specify 2 Manifests for apps and we can just use the `main` manifes to toggle if `usesCleartextTraffic` should be enabled or not.

This will have to be replicated in the template repository.

Changelog:
[Android] [Added] - Add support to specify a single Manifest rather than 2 (main/debug) by using the `usesCleartextTraffic` manifest placeholder which is autoconfigured by RNGP.

Reviewed By: cipolleschi

Differential Revision: D78425139
…er (facebook#52647)

Summary:
Pull Request resolved: facebook#52647

This removes the need to specify 2 Manifests for apps and we can just use the `main` manifes to toggle if `usesCleartextTraffic` should be enabled or not.

This will have to be replicated in the template repository.

Changelog:
[Android] [Added] - Add support to specify a single Manifest rather than 2 (main/debug) by using the `usesCleartextTraffic` manifest placeholder which is autoconfigured by RNGP.

Reviewed By: cipolleschi

Differential Revision: D78425139
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78425139

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jul 18, 2025
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in d89acc1.

kikoso pushed a commit to kikoso/react-native that referenced this pull request Aug 26, 2025
…er (facebook#52647)

Summary:
Pull Request resolved: facebook#52647

This removes the need to specify 2 Manifests for apps and we can just use the `main` manifes to toggle if `usesCleartextTraffic` should be enabled or not.

This will have to be replicated in the template repository.

Changelog:
[Android] [Added] - Add support to specify a single Manifest rather than 2 (main/debug) by using the `usesCleartextTraffic` manifest placeholder which is autoconfigured by RNGP.

Reviewed By: cipolleschi

Differential Revision: D78425139

fbshipit-source-id: 9173a014b387d5aed5f7087fa69b7bd49c220f2c
@Ikthegreat
Copy link

@cortinico Hi, thank you for the changes in this PR.

I have a question regarding usesCleartextTraffic handling after upgrading to React Native 0.81.5.

In our project, we maintain a custom dev buildType, which is intended to behave similarly to debug (for debugging) while being closer to release in terms of build configuration. This buildType has been used internally for some time without issues.

After upgrading to RN 0.81.5, we started seeing a manifest merge error when building dev, caused by a missing usesCleartextTraffic placeholder. Upon investigation, we found that react-native-gradle-plugin now explicitly injects usesCleartextTraffic values for the default debug and release buildTypes.

From what I can see, configureBuildTypesForApp in RNGP branches only on debug and release. This made me wonder:
1. For custom buildTypes added by the app (like our dev buildType), what is the recommended way to apply usesCleartextTraffic?
Should this be fully handled at the app level via manifestPlaceholders, or is there an intended extension point we should rely on?
2. I also noticed that a new debugOptimized buildType was introduced around this change.
Since it is not explicitly handled in configureBuildTypesForApp, how is usesCleartextTraffic applied to debugOptimized internally?
3. As a general design question:
It seems that applying usesCleartextTraffic = true only for debug, and false for all other buildTypes (including release-like variants), would be closest to the previous behavior.
Is there a reason why this simpler branching strategy was not adopted?

I’m commenting on this PR because it appears to be the most closely related change in changelog.md, but please let me know if there is a more appropriate issue or PR where this question should be raised instead.

Thanks in advance for your guidance.

@cortinico
Copy link
Contributor Author

Happy to answer @Ikthegreat

From what I can see, configureBuildTypesForApp in RNGP branches only on debug and release. This made me wonder:

The part you're missing is

maybeCreate("debugOptimized").apply {
manifestPlaceholders["usesCleartextTraffic"] = "true"
initWith(debug)
matchingFallbacks += listOf("release")
externalNativeBuild { cmake { arguments("-DCMAKE_BUILD_TYPE=Release") } }
}

Essentially we create debugOptimized with initWith(debug). So that build type will inherit the Manifest from the debug one. This makes is easier for us to maintain as we don't need a new manifest just for debugOptimized.

  1. For custom buildTypes added by the app (like our dev buildType), what is the recommended way to apply usesCleartextTraffic?

If your custom build type needs to connect to Metro/React Native DevTools, then you need usesCleartextTraffic. That's beacuse the bundler generally runs on http://localhost:8081 and having HTTPS on localhost is a PITA.

Should this be fully handled at the app level via manifestPlaceholders, or is there an intended extension point we should rely on?

You should be able to use manifestPlaceholders and specify it in the same way as we do inside RNGP

  1. I also noticed that a new debugOptimized buildType was introduced around this change.
    Since it is not explicitly handled in configureBuildTypesForApp, how is usesCleartextTraffic applied to debugOptimized internally?

See my above answer related to initWith(debug)

  1. As a general design question:
    It seems that applying usesCleartextTraffic = true only for debug, and false for all other buildTypes (including release-like variants), would be closest to the previous behavior.
    Is there a reason why this simpler branching strategy was not adopted?

I believe I already answered this essentially. Let me know if something is still unclear.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants