Skip to content

Conversation

@shubhamd99
Copy link

@shubhamd99 shubhamd99 commented Jan 11, 2026

Summary

This patch fixes a build failure on Android in React Native 0.83 caused by the use of std::format in
react/renderer/core/graphicsConversions.h. Android builds use C++17 and the Android NDK does not support
std::format (a C++20 feature), which leads to compile/link errors (e.g., undefined symbol and missing
std::format on Windows and other environments).

The problematic line has been replaced with a C++17-compatible implementation using std::to_string + "%".

Motivation

  • std::format is not available in the Android NDK’s C++17 toolchain.
  • This issue causes native build errors on Windows, Linux, and macOS when building React Native apps on
    0.83 and potentially other versions that include this code.
  • The original code breaks Fabric/Codegen builds due to missing symbols and unsupported language features.

This commit resolves the issue by using a supported alternative that produces the same result.

Changes

  • File: ReactCommon/react/renderer/core/graphicsConversions.h

  • Before:

    case YGUnitPercent:
      return std::format("{}%", dimension.value);
    
    

Summary:

Changelog:

Test Plan:

Fix build crash on windows 11
@meta-cla
Copy link

meta-cla bot commented Jan 11, 2026

Hi @shubhamd99!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@shubhamd99 shubhamd99 changed the title Update graphicsConversions.h Update graphicsConversions.h (Patch the std::format bug in RN 0.83) Jan 11, 2026
@shubhamd99 shubhamd99 changed the title Update graphicsConversions.h (Patch the std::format bug in RN 0.83) fix(android): replace std::format with std::to_string in graphicsConversions.h for C++17 compatibility Jan 11, 2026
@shubhamd99 shubhamd99 mentioned this pull request Jan 11, 2026
@shubhamd99 shubhamd99 closed this Jan 11, 2026
@shubhamd99 shubhamd99 reopened this Jan 11, 2026
@meta-cla
Copy link

meta-cla bot commented Jan 11, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 Jan 11, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jan 11, 2026
@cipolleschi
Copy link
Contributor

I don't think this is the right fix. React Native should build with C++20.
iOS already builds with C++20 and Hermes is building with C++20 too. I'm surprised to learn that Android is building with C++17, tbh.
@cortinico is this a regression?

@cortinico
Copy link
Contributor

I don't think this is the right fix. React Native should build with C++20.
iOS already builds with C++20 and Hermes is building with C++20 too. I'm surprised to learn that Android is building with C++17, tbh.

We do already build with C++20 on Android:

so I'm unsure what this fix is about @shubhamd99
Are you trying to build React Native using C++17?

@shubhamd99
Copy link
Author

shubhamd99 commented Jan 13, 2026

React Native should build with C++20.

not able to build with std::format in android in windows 11, its throwing error during gradlew run

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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants