Commit Graph

66 Commits

Author SHA1 Message Date
Nicola Corti d5d21d0614 Remove possibility to newArchEnabled=false in 0.82 (#53025)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53025

It's now time to say goodbye to the Legacy Architecture :')

This change hardcodes the `newArchEnabled` property to true, and warns the users
if they're attempting to set it to false.

Changelog:
[Android] [Breaking] - Remove possibility to newArchEnabled=false in 0.82

Reviewed By: cipolleschi

Differential Revision: D78560296

fbshipit-source-id: ccfc45d2f7f21cc20e063cb901d76be3d41458d6
2025-08-05 05:11:12 -07:00
Nicola Corti 9013a9e666 RNGP - Fix a race condition with codegen libraries missing sources (#52803)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52803

I've just realized that our build suffer from a race condition. Specifically
libraries codegen needs to be executed before the app starts the evaluating CMake files.
Otherwise this could lead to a lot of missing files or folders.

Changelog:
[Android] [Fixed] - **rngp:** Fix a race condition with codegen libraries missing sources

Reviewed By: huntie

Differential Revision: D78886347

fbshipit-source-id: f59c201d2eab651bc4a08cf5a795acd379d18186
2025-07-24 05:23:38 -07:00
Nicola Corti eb2461c7c9 Create a debugOptimized buildType for Android (#52648)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52648

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

Reviewed By: cipolleschi

Differential Revision: D78425138

fbshipit-source-id: c1e9ea3608e7df10fb871a5584352f0747cf560b
2025-07-18 08:07:54 -07:00
Nicola Corti 5e3edafec6 Migrate RNTester to use {usesCleartextTraffic} Manifest Placeholder (#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: https://github.com/facebook/react-native/pull/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" />

Rollback Plan:

Reviewed By: cipolleschi

Differential Revision: D78351347

Pulled By: cortinico

fbshipit-source-id: 568a484ba8d2ee6e089cabc95451938e853fbc54
2025-07-18 08:07:54 -07:00
Nicola Corti 625f69f284 @DeprecatedInNewArchitecture -> @Deprecated (#52399)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52399

I'm raising the deprecation warnings for those methods that are using legacy arch.
Previously the `DeprecatedInNewArchitecture` was not generating warnings for user in their builds, while now the Kotlin's/Java's `DeprecatedInNewArchitecture` it will.

Changelog:
[Android] [Changed] - Introduce more deprecation warnings for Legacy Arch classes

Reviewed By: mdvacca

Differential Revision: D77736713

fbshipit-source-id: bc21729ed8253d3ec6b6a40577bcd76622c3f8a6
2025-07-07 10:20:43 -07:00
Nicola Corti 6cb8dc37c7 RNGP - Add support for exclusiveEnterpriseRepository (#52378)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52378

This adds a Gradle property called `exclusiveEnterpriseRepository`
that users can set in their `android/gradle.properties` as such:

```diff
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

+exclusiveEnterpriseRepository=https://my.internal.proxy.net/
```

This will remove all the existing Maven repositories and only use the internal mirror they have.

Changelog:
[Android] [Added] - RNGP - Add support for `exclusiveEnterpriseRepository` to specify an internal Maven mirror.

Reviewed By: mdvacca

Differential Revision: D77667573

fbshipit-source-id: 835004d2ae7aa4e250b6f7a88a41918b573f5bd5
2025-07-03 02:27:08 -07:00
Mathieu Acthernoene 09ef774ff6 Add edge-to-edge opt-in support (#52088)
Summary:
This follows https://github.com/facebook/react-native/pull/47554

Compared to the initial proposal, I had to remove the `edgeToEdgeEnabled` property from the root `gradle.properties` and put it in the app `gradle.properties` instead (explaining the `AgpConfiguratorUtils.kt` / `GenerateEntryPointTask.kt` / `ProjectUtils.kt` / `PropertyUtils.kt` changes)

This PR:
- Enable edge-to-edge for `MainActivity` (when `edgeToEdgeEnabled` is set to `true`)
- Disable `StatusBar` `backgroundColor` and `translucent` (when `edgeToEdgeEnabled` is set to `true`)
- Enforce `statusBarTranslucent` and `navigationBarTranslucent` on `Modal` when edge-to-edge is enabled
- Add an `isEdgeToEdge` constant to `DeviceInfoModule` for [`react-native-is-edge-to-edge`](https://github.com/zoontek/react-native-edge-to-edge/tree/main/react-native-is-edge-to-edge) detection

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

- [Android] [Added] - Add edge-to-edge opt-in support

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

Test Plan:
- Update `enableEdgeToEdge` value in `packages/rn-tester/android/app/gradle.properties`
- Recompile

https://github.com/user-attachments/assets/4c6beb98-fa88-427c-b62d-a42ffe5330f0

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76834213

Pulled By: alanleedev

fbshipit-source-id: c39b2cff1a5e94e31306e3b35651aa2de83d2fe6
2025-06-27 06:16:23 -07:00
Andrew Datsenko 74b6acb1f0 Add gflags (#52015)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52015

Changelog: [Internal]
Add gflags to fantom_tester so we can pass in data like featureFlags

Reviewed By: cortinico

Differential Revision: D76618409

fbshipit-source-id: a18e642a02c405eef972a7418a606a5980253b6a
2025-06-17 04:18:08 -07:00
Nicola Corti 8174d02811 Cleanup all the JSC 1st party code. (#51949)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51949

This code is no longer necessary now that JSC support is offered via
https://github.com/react-native-community/javascriptcore

Instructions for users on how to continue using JSC are available in the README of such library.

Changelog:
[Android] [Removed] - Remove 1st party JSC support

Reviewed By: javache

Differential Revision: D76420382

fbshipit-source-id: f8e61556bb02fe4d5b34f89b40f8e5e38ac1c8d6
2025-06-16 10:30:39 -07:00
Nicola Corti 7ec2839955 Update Nightly URL for newly published versions on central.sonatype.com (#52004)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52004

This is necessary because the snapshots are now going to be published on a different repository:
central.sonatype.com.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D76596802

fbshipit-source-id: 424fb1134e41502d53b76209fba325c895c79ba8
2025-06-13 10:09:47 -07:00
Nicola Corti 4f9090bc57 Bump AGP to 8.10.x (#51854)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51854

AGP 8.10.x comes with a source breaking change:
https://issuetracker.google.com/issues/416890061

This shoudl fix it and unblock us for the 0.81 release.

Changelog:
[Android] [Changed] - Bump AGP to 8.10.x

Reviewed By: huntie

Differential Revision: D76053989

fbshipit-source-id: b0fe19544c79d65002127176f2722cdfd85f0a3c
2025-06-06 04:48:02 -07:00
Nicola Corti 5a476e94be RNGP - Ignore the legacyWarningsEnabled property if provided (#50929)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50929

We decided to change the warning model for LegacyArch/NewArch.

I'm currently removing the infra to read the `legacyWarningsEnabled` Gradle property if provided.

Warnings will be enabled by default for all Legacy Arch users in the new model.

This change was never shipped in a numbered version, so that's not breaking.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D73591315

fbshipit-source-id: a46fade91b46fcc9b81984577161c046dc0939b6
2025-04-25 07:49:59 -07:00
Mateo Hrastnik d816ba0a70 Inject dev machine IP on Android and improve error message when connection fails (#49166)
Summary:
I've implemented a feature that automatically bundles the Metro Bundler's IP address into Android builds. This change aligns the Android development experience with iOS, allowing the app to maintain a connection to the Metro Bundler even when disconnected from USB.

Currently, in iOS builds, the IP address of the computer running the Metro Bundler is automatically bundled into the app, ensuring seamless connectivity even when the device is disconnected from USB. In contrast, Android developers must manually input the IP address if the USB connection is lost, which can be tedious and error-prone.

More info in discussion thread: https://github.com/react-native-community/discussions-and-proposals/issues/870

I anticipate that a change where making IP the default method of connection will result in a lot of people running into issues where they can't connect to Metro server (for example, if they're on a different network, or they disable wifi). So I also changed the default error message you get in case the app can't connect to the bundler and updated the "Change Bundle Location" dev menu.

The previous error message

```
Unable to load script. Make sure you're either
running Metro (run 'npx react-native start') or
that your bundle 'RNTesterApp.android.bundle' is
packaged correctly for release.
```

was changed to:

```
Unable to load script.

Make sure you're running Metro (npx react-native start)
or that your bundle 'RNTesterApp.android.bundle' is
packaged correctly for release.

The device must be on the same WiFi as your laptop to
connect to Metro.

To use USB instead, shake the device to open the dev
menu and set the bundler location to 'localhost: 8081'
and run:
  adb reverse tcp:8081 tcp:8081

```

![image](https://github.com/user-attachments/assets/f4002c7a-ff8a-4518-acf7-85af4257e05b)

And the new dev menu UI looks like this:
![image](https://github.com/user-attachments/assets/ecaf6922-f074-4db9-b723-c4b18ececd91)

The two buttons with "10.0.2.2:8081" and "localhost:8081" are suggestions which when tapped fill the input with the text from the button. The first button suggests the IP of the development machine, and the second one is hardcoded to localhost:8081.

## Changelog:

[ANDROID] [CHANGED] - Automatically use Metro bundler IP address when installing apps on Android

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

Test Plan:
I've tested the implementation on a physical device and on emulator and it's working solid. However, I would invite further testing in order to catch possible edge cases.

I've recorded common scenarios

Scenario 1:
	Device doesn't have the app installed.
	We connect the device via USB, install the app and open it.
	Device is on the same network as the dev machine.
	Bundler location is by default set to the IP of the dev machine.
	When starting app, the app is able to connect to the dev machine and download the bundle.

Scenario 2:
	Device doesn't have the app installed.
	Wi-Fi is turned off on the device but device is connected via USB
	We install the app and open it.
	Bundler location is by default set to the IP of the dev machine.
	When starting app, the app is not able to connect to the dev machine and shows the error message.
	After opening the dev menu we see that the IP is set to the IP of the dev machine.
	We click the "localhost" option in the dev menu and click apply
	After that the app is able to connect to the dev machine and download the bundle (via USB) since the traffic is forwarded using adb reverse.

Notes:
	When we set an IP in the dev menu, the app will persist it.
	If we connect the device via USB and reinstall the app the persisted data stays the same, so the previously set IP will be used.
	However, the IP of the dev machine will be displayed as an option in the dev menu.

https://github.com/user-attachments/assets/cc2da5d4-de07-4980-a61c-68ca53db74c7

https://github.com/user-attachments/assets/407b8871-8b83-4a6b-a833-f87ddc0afc82

Reviewed By: huntie

Differential Revision: D69664231

Pulled By: cortinico

fbshipit-source-id: 5a339be50a17a59202416b99e72f4397d8ff4805
2025-04-09 11:58:05 -07:00
Nicola Corti 7ca2811750 Add a legacyWarningsEnabled property to enable Legacy Warnings on NewArch (#50470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50470

This diff introduces a new property called `legacyWarningsEnabled` for `gradle.properties` that
toggles the Legacy Arch warnings for users.

I've also introduced a new `ReactNativeApplicationEntryPoint` that is generated by RNGP. This class
effectively wrap `DefaultNewArchitectureEntryPoint` by setting warnings and also invoking SoLoader.
It will reduce the errors in the user space.

As of now warnigns appear in Logcat, but I'm looking into adding some UI in a subsequent diff.

Changelog:
[Android] [Added] - Add a `legacyWarningsEnabled` property to enable Legacy Warnings on NewArch

Reviewed By: mdvacca

Differential Revision: D72383907

fbshipit-source-id: bcd659a23ec5b468958124f0f6650ff72d01ce81
2025-04-04 08:17:07 -07:00
Nicola Corti 38a7ba7c2a Do not warn for JSC deprecation on react-native-github (#50172)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50172

This specific warning is only for React Native users.

We don't need this warning on console for RNtester so I'm excluding react-native-github
project from the list of project where this warning gets fired.

Changelog:
[Internal] [Changed] - Do not warn for JSC deprecation on react-native-github

Reviewed By: mdvacca

Differential Revision: D71556035

fbshipit-source-id: 8ab625eb2c090416119903dbc9c29afac51c91bd
2025-03-20 10:48:12 -07:00
Nicola Corti a0528d834c RNGP - Better compatibility with Kotlin 2.1.x (#49977)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49977

See: https://github.com/facebook/react-native/issues/48274
This makes our integration with Kotlin 2.1.x easier.

Changelog:
[Android] [Changed] - Better compatibility with Kotlin 2.1.x

Reviewed By: cipolleschi

Differential Revision: D71034044

fbshipit-source-id: 9a26ed28ae4770a5c05a4113f4d86c1b97063db3
2025-03-12 10:10:46 -07:00
Kudo Chien 90e27c2b4f show JSC removal message on Android (#49709)
Summary:
show build time jsc removal warning. https://github.com/facebook/react-native/issues/49692 but for android

![Screenshot 2025-02-27 at 3 41 43 PM](https://github.com/user-attachments/assets/a4fe6d52-5e05-45b0-a403-c71372dfba06)

## Changelog:

[ANDROID] [CHANGED] - Add a build time JSC lean core warning

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

Test Plan: - test on rn-tester. rn-tester has a jsc build variant. it shows the warning anyway. commenting out `enableHermesOnlyInVariants` will suppress the warning.

Reviewed By: rshest

Differential Revision: D70323283

Pulled By: cortinico

fbshipit-source-id: 632a8b9086c5d90d7f14ea705464356a1292bcad
2025-02-27 08:38:35 -08:00
Marc Rousavy 778382ad3d RNGP - Add option to disable bundle compression (was: Make all React Native apps start 12% faster) (#49449)
Summary:
Okay the title is a bit clickbaity, but this is actually true. (on Android)

We (Janic, Szymon, Ruby and Me) discovered something interesting. React Native uses `mmap` for mapping the JS bundle to RAM, to avoid having to load the entire thing instantly at app startup.
Ruby doubted that this was true - so we investigated.

Apparently on Android, resources are **compressed**. And if the JS bundle is stored compressed, it has to be uncompressed before it can be loaded into RAM, hence not allowing it to be mmapp'ed! (see [`_CompressedAsset::getBuffer`](https://cs.android.com/android/platform/superproject/+/master:frameworks/base/libs/androidfw/Asset.cpp;l=903?q=Asset.cpp))

So with this PR, we now add `.bundle` files to `noCompress` in the react-native gradle plugin, which disables compression for the JS bundle.

We discovered while improving the performance of one of our clients: **Discord**.
In our tests, **this improved the TTI of the Discord app by 400ms!! (or 12%)** 🤯🚀

NOTE: Yes, the .apk will now be bigger. But; Google Play compresses it anyways, so the **download size** of your .apk will likely not increase by much. It will be bigger on disk though.

## Changelog:

[ANDROID] [CHANGED] Add option to disable bundle compression to improve startup time

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

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

Test Plan:
### 1. Verify compression is disabled

Build two apps, one with this patch and one without. When I did this using the RN community template, the one without this patch was 47,6 MB, and the one with this patch was 48 MB in size. So the .apk got bigger, which is what we expected

### 2. Verify app startup is faster

Use tools like react-native-performance or custom markers to measure TTI. In our tests, we shaved off 400ms from the startup time, which was about 12% of Discord's total TTI. (on a low-end Android device)
In Expensify, we improved the TTI by 14-20% with this change (source: https://github.com/Expensify/App/pull/56930)

Reviewed By: javache, cipolleschi

Differential Revision: D69742221

Pulled By: cortinico

fbshipit-source-id: bd59d77662bd30a3acdbb2e9f8d8f23db922c3f2
2025-02-19 18:42:51 -08:00
Nicola Corti bbfccd088b RNGP - Convert if to when in getPackagingOptionsForVariant (#49426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49426

This is a nit, but I'm following up on a review comment that was left behind.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D69656370

fbshipit-source-id: 76de4d77d9993bd9a35d7df019a6cebcce13d632
2025-02-17 06:51:50 -08:00
Nicola Corti 43cffb96db Gradle Configuration Cache - Round 3 (#49439)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49439

This is the next part of a series of diff needed to enable G. Configuration Cache:
https://docs.gradle.org/current/userguide/configuration_cache.html
as it will make our CI faster (and will be the default in the future Gradle version).

Here I'm removing the `onlyIf` lambdas to make some tasks CC friendly.

The problem is that some `onlyIf` lambdas can't easily be serialized. Here I'm cleaning up
the problematic one to move the condition checks at execution time

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D69664732

fbshipit-source-id: a457b2fae8114568ec4e04d772c9944022b1e1a5
2025-02-17 03:35:43 -08:00
Nicola Corti 0014265795 Gradle Configuration Cache - Round 2 (#49438)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49438

This is the second part of a series of diff needed to enable G. Configuration Cache:
https://docs.gradle.org/current/userguide/configuration_cache.html
as it will make our CI faster (and will be the default in the future Gradle version).

Here I'm making the exec tasks CC friendly.

The problem is that previously we were using explicit streams which are not CC friendly
for stderr/stdout. The solution is to create a custom task and handle files as input
properties.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D69662246

fbshipit-source-id: ad7e82e52b12d508ee15b68408882fdc3516d287
2025-02-17 03:35:43 -08:00
Kudo Chien 66032f22b8 pull out jsctooling when useThirdPartyJSC is true (#49365)
Summary:
an effort of lean core for jsc: https://github.com/Kudo/discussions-and-proposals/blob/%40kudo/lean-core-jsc/proposals/0836-lean-core-jsc.md

## Changelog:

[ANDROID] [CHANGED] - exclude `jsctooling` when `useThirdPartyJSC` gradle property is true

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

Test Plan:
- ci passed
- test from https://github.com/react-native-community/javascriptcore/pull/4

Reviewed By: cipolleschi

Differential Revision: D69654289

Pulled By: cortinico

fbshipit-source-id: 148e07c7114dde05c2014522f9c56119f7f6f0ce
2025-02-14 03:52:30 -08:00
Nicola Corti e78a6d844c RNGP - Do not access .project inside GenerateCodegenArtifactsTask (#49400)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49400

We should not invoke anything on the `project` property inside thet task.
That will break Gradle Configuration Caching which is becoming the default in the next version of Gradle.

This fixes it for the `GenerateCodegenArtifactsTask` task.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D69592464

fbshipit-source-id: 72bab3f29299313875f2e7abd1b701c9d74bd2a1
2025-02-14 02:56:32 -08:00
Nicola Corti 0ce56ad953 RNGP - Do not access .project inside GenerateCodegenSchemaTask (#49399)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49399

We should not invoke anything on the `project` property inside thet task.
That will break Gradle Configuration Caching which is becoming the default in the next version of Gradle.

This fixes it for the `GenerateCodegenSchemaTask` task.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D69592463

fbshipit-source-id: 56e78b1bdc113ae402cc90960faa05cd73d5b97d
2025-02-14 02:56:32 -08:00
Nicola Corti 0dd901701a RNGP - Do not access .project inside BuildCodegenCLITask (#49398)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49398

We should not invoke anything on the `project` property inside thet task.
That will break Gradle Configuration Caching which is becoming the default in the next version of Gradle.

This fixes it for the `BuildCodegenCLITask` task.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D69592465

fbshipit-source-id: fc69896b61968ace7b7762f873cfa7eaa50c8b17
2025-02-14 02:56:32 -08:00
Nicola Corti e6690cb4a7 Disable console logging for hermesc (#49301)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49301

The hermesc logging is extremely noisy and not relevant for the users. I'm disabling it for the task that runs metro+hermesc (only for the hermesc) part.

Changelog:
[Internal] [Changed] - Disable console logging for hermesc

Reviewed By: robhogan

Differential Revision: D69399156

fbshipit-source-id: e5f8722b33d30675aba5a8aa82c456be21254b0c
2025-02-11 06:11:08 -08:00
Janic Duplessis 2aed264695 Fix exclude .d.ts test in GenerateCodegenSchemaTaskTest (#49238)
Summary:
I wanted to test exclusion of .d.ts files in https://github.com/facebook/react-native/pull/49227, but it also has node_modules so it will not test that condition correctly.

## Changelog:

[INTERNAL] [FIXED] - Fix exclude .d.ts test in GenerateCodegenSchemaTaskTest

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

Test Plan: Run tests

Reviewed By: cipolleschi

Differential Revision: D69291695

Pulled By: cortinico

fbshipit-source-id: 46b9367f3466b9cd49232a0565e5778a06b43990
2025-02-07 01:55:34 -08:00
Janic Duplessis e9e0d8c2f7 Improve input files for codegen gradle task (#49227)
Summary:
In some projects we have conventions of using .tsx extension even for files without react components, we had issues where codegen wasn't updated properly.

I debugged the files included in a large project and made some improvements:

- Include tsx and jsx files
- exclude nested node_modules
- exclude ts type def files

## Changelog:

[ANDROID] [FIXED] - Improve input files for codegen gradle task

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

Test Plan: Tested in a large app using codegen. I inspected the files that are included in the task inputs and made sure it works with first party and 3rd party modules.

Reviewed By: cipolleschi

Differential Revision: D69254204

Pulled By: cortinico

fbshipit-source-id: 368408e9719e9b5c9839dd873430b86ae4a062c7
2025-02-06 11:52:25 -08:00
Riccardo Cipolleschi 6c6d3413cf Remove CircleCI references from gradle and android (#49118)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49118

We finished the migration away from CircleCI, so we are cleaning up the codebase.

This change updates references to CircleCI from gradle.

## Changelog:
[Internal] - Remove references from CircleCI in RNGP

Reviewed By: cortinico

Differential Revision: D69047484

fbshipit-source-id: 4ab40be62e6769eb3a8f65136464eed6628d47a4
2025-02-03 10:02:19 -08:00
Nicola Corti 3702c986ed RNGP - Update comment on INCLUDE_JITPACK_REPOSITORY_DEFAULT (#48896)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48896

This comment is not exact and should be updated.

Changelog:
[Internal] [Changed] -

Reviewed By: yungsters

Differential Revision: D68556425

fbshipit-source-id: 67427ff325809907fdeba1c6a90b84b97713bf5e
2025-01-23 10:52:34 -08:00
Nicola Corti d9a77e1d02 RNGP - Do not access project. during task execution. (#48745)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48745

This is the first step in a series of diff to make RNGP more Gradle-compliant (specifically for the sake of configuration caching).

Specifically the problem in those 2 tasks is that we're accessing `project.copy()` and other
functions from the `project` field.

The project should never be accessed at execution time. See more on this here:
https://docs.gradle.org/8.12/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

This diff fixes it.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D68282777

fbshipit-source-id: 6d474f266b5bc50fba57c8cd478173c995864bbc
2025-01-17 08:56:46 -08:00
Nicola Corti 63442d3757 RNGP - Cleanup prealpha logic from the Gradle Plugin (#48689)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48689

We don't intent to use the prealpha logic in the near future so it makes sense to remove it for
to simplify our already complicated release process. We can always revive it if we wish.

Changelog:
[Internal] [Changed] - RNGP - Cleanup prealpha logic from the Gradle Plugin

Reviewed By: cipolleschi

Differential Revision: D68205665

fbshipit-source-id: 81d5257544df97b566421164944e3b6e71f06635
2025-01-15 04:30:37 -08:00
Nicola Corti 7bb92a3c2d refactor: Remove unnecessary parameter from configureRepositories (#48596)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48596

The second parameter of `configureRepositories` was unused. Let's remove it.

Changelog:
[Internal] [Changed] - refactor: Remove unnecessary parameter from configureRepositories

Reviewed By: cipolleschi

Differential Revision: D68016105

fbshipit-source-id: 9fa05cd33e2f7a6986cf1fcdef0d75e74f315843
2025-01-10 07:38:08 -08:00
Nicola Corti a98528e609 Make the addition of JitPack repository configurable (#48595)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48595

Historically React Native used to include the JitPack repository be default in the default repositories.

This sadly exposes React Native projects to supply chain attacks as explained here:
https://blog.oversecured.com/Introducing-MavenGate-a-supply-chain-attack-method-for-Java-and-Android-applications/

Moreover, artifacts on Jitpack are not GPG signed it's complicated to verify the identity of artifact authors.
I'm introducing a Gradle property to control if Jitpack should be included by default or not.

User can control this behavior by changing their `gradle.properties` file as such:

```
includeJitpackRepository=false
```

The default value of this property is currently true, but we're looking into changing it to false in the future.

Changelog:
[Android] [Added] - Make the addition of JitPack repository configurable

Reviewed By: cipolleschi

Differential Revision: D68016028

fbshipit-source-id: 392513fef389a4835b4e00a8184459e00d51fdd0
2025-01-10 07:38:08 -08:00
Kudo Chien e42a3a6b84 Migrate jsc-android to mavenCentral (#47972)
Summary:
Since people mostly use Hermes, it doesn't make sense to download jsc-android from npm even when jsc is not used. This PR migrates the jsc-android to [mavenCentral](https://repo1.maven.org/maven2/io/github/react-native-community/jsc-android/2026004.0.0/). The new jsc-android supports Android 16KB memory page sizes and packaged by prefab.
Relevant PRs:
  - https://github.com/react-native-community/jsc-android-buildscripts/pull/184
  - https://github.com/react-native-community/jsc-android-buildscripts/pull/185

## Changelog:

[ANDROID] [CHANGED] - Migrate jsc-android to mavenCentral

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

Test Plan: CI passed

Reviewed By: cipolleschi

Differential Revision: D66772407

Pulled By: cortinico

fbshipit-source-id: e34d2d138996e394763ef67d7aad65bb3e7b13dc
2024-12-06 12:50:34 -08:00
Vojtech Novak 9147b0753a fix IOException in BuildCodegenCLITask (#48008)
Summary:
building RN tester with 0.77 rc-0 doesn't work now because of `java.io.IOException:  No such file or directory` on line 48.

`buildDirectory` is a Gradle property representing a file

https://github.com/facebook/react-native/pull/47552 removes this file altogether so feel free to close if that one is the "right one"

## Changelog:

[ANDROID] [FIXED] - fix IOException in `BuildCodegenCLITask`

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

Test Plan: After this change, building RN tester works.

Reviewed By: cortinico

Differential Revision: D66650038

Pulled By: robhogan

fbshipit-source-id: 11cd83493fa118c6b79d11c9113228dd3971a803
2024-12-02 05:09:54 -08:00
Nicola Corti 490db92562 Gradle to 8.11.1 (#48026)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48026

This should mitigate this particular issue we're seeing on Windows:
- https://github.com/facebook/react-native/issues/46210

Changelog:
[Android] [Changed] - Gradle to 8.11.1

Reviewed By: javache

Differential Revision: D66600321

fbshipit-source-id: d58437485222e189d90bcf4d6b41ca956449ed22
2024-12-02 03:22:32 -08:00
Nicola Corti 1f62529dc4 Properly handle paths with spaces in autolinking (#47388)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47388

Fixes https://github.com/facebook/react-native/issues/47364
Fixes https://github.com/facebook/react-native/issues/47377
Fixes https://github.com/facebook/react-native/issues/37124

We're having problems is a path contains a space ' ' because when autolinking,
the `add_subdirectory()` function of CMake consider the path with space as 2 parameters.

This fixes it by properly quoting the path.

Changelog:
[Android] [Fixed] - Properly handle paths with spaces in autolinking

Reviewed By: cipolleschi

Differential Revision: D65434413

fbshipit-source-id: b9147482f98f7e222405cc8d9e6f3c17a5f4ed02
2024-11-05 03:32:16 -08:00
Alan Lee 65cdd5b82c Enable 16KB page size binaries for RN libraries + hermes (#47042)
Summary:
X-link: https://github.com/facebook/hermes/pull/1557

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

Add native build flags to support 16KB page size

- https://developer.android.com/guide/practices/page-sizes#compile-r27-higher

Changelog:
[Android][Added] add cmake arguments to support 16KB page size for native libraries

Reviewed By: cortinico

Differential Revision: D64446876

fbshipit-source-id: 5c6b7874a8837c7ebc9b3e9267ce11fb152bf535
2024-10-31 18:45:31 -07:00
Nicola Corti 2c4567562c RNGP - Pass PROJECT_ROOT_DIR to CMake (#46958)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46958

This will make it easier to link against custom C++ TM which will most likely live inside ./shared or
some other paths outside of ./android.

CMake will have access to `PROJECT_ROOT_DIR` which points to ./android (the folder where the settings.gradle file exists).

Changelog:
[Internal] [Changed] - RNGP - Pass PROJECT_ROOT_DIR to CMake

Reviewed By: cipolleschi

Differential Revision: D64183641

fbshipit-source-id: 347256c04f10e92cf5a13e9c70db16aa29bcb741
2024-10-11 03:34:54 -07:00
Nicola Corti c441de5a47 Fix build warning for prepareGlog (#46756)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46756

prepareGlog was firing a warning due to a duplicate config.h file. Here I'm setting so that the file is always overridden (which is the desired behavior) to suppress this warning.

Changelog:
[Internal] [Changed] - Fix build warning for prepareGlog

Reviewed By: cipolleschi

Differential Revision: D63696664

fbshipit-source-id: 83b78afea09c4a5d39f341dd5b604cec466470ae
2024-10-01 10:04:57 -07:00
Nicola Corti d1f47f7ad5 Silence unnecessary Gradle outputs - Part 1 (#46704)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46704

Our build log for Gradle is extremely noisy due to Hermes.
Here I'm suppressing all the build output from Hermes as we can't really do much from that side of the build.

This should make it easier for folks on GitHub Actions to immediately spot where are failures.

Changelog:
[Internal] [Changed] - Silence unnecessary Gradle outputs

Reviewed By: GijsWeterings

Differential Revision: D63541175

fbshipit-source-id: d1a60098c317ff9e8c9575b5b8b2aab639f28f2f
2024-09-30 03:55:54 -07:00
Nicola Corti c005609b01 Properly set REACTNATIVE_MERGED_SO for autolinked libraries. (#46606)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46606

This fixes this issue reported here:
https://github.com/react-native-community/discussions-and-proposals/discussions/816#discussioncomment-10673136

reported by both SWM and Expo.

The problem is that `REACTNATIVE_MERGED_SO` is not properly set for autolinked libraries so they can't access it
to understand if the version of ReactNative has merged so libraries or not.
This fixes it, I've tested against
https://github.com/tomekzaw/repro-reactnative-merged-so
reproducer provided by tomekzaw

Changelog:
[Android] [Fixed] - Properly set `REACTNATIVE_MERGED_SO` for autolinked libraries

Reviewed By: rubennorte

Differential Revision: D63262687

fbshipit-source-id: c505dce9036bb4cd0366b7ab99412368963273af
2024-09-24 03:35:15 -07:00
Nicola Corti d7884a6bb8 RNGP - Sanitize the output of the config command (#46482)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46482

Fixes https://github.com/facebook/react-native/issues/46443
Fixes https://github.com/facebook/react-native/issues/46134

I'm sanitizing the output of the `config` command + I've added some more logging in case of failure.

Changelog:
[Android] [Fixed] - RNGP - Sanitize the output of the config command

Reviewed By: cipolleschi

Differential Revision: D62641979

fbshipit-source-id: c13d27a42beeb7a973c1802e7204631d49d3d09b
2024-09-13 10:42:20 -07:00
Thomas Nardone c942469700 Re-enable ktfmt on RN (#46441)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46441

Changelog: [Internal]

Reviewed By: zertosh

Differential Revision: D62518893

fbshipit-source-id: ca2ff83018716a4dc1e2dcfb8596138d088ce9f4
2024-09-11 19:06:25 -07:00
Hampus Sjöberg 833c3a2cf5 fix: RNGP autolink not properly filter out pure C++ TurboModules (#46381)
Summary:
Hey.

The react-native gradle plugin didn't properly filter out [Pure](https://github.com/react-native-community/cli/pull/2387) C++ TurboModules for autolinking, which caused build failures as a non-existing gradle dependency would be emitted.

This makes Pure C++ TurboModules work again for Android.

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

[ANDROID][FIXED] Fix autolinking issues for Pure C++ TurboModules

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

Test Plan:
https://github.com/hsjoberg/rn75autolinkregression

Try running this repro project to observe the error:

```
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/coco/Projects/Blixt/rn75autolinkregression/example/android/app/build.gradle' line: 54

* What went wrong:
A problem occurred evaluating project ':app'.
> Project with path ':react-native-cxx-turbomodule' could not be found in project ':app'.
```

Simply add the 1-line code from this PR to make the build succeed.

Cheers.

Reviewed By: cipolleschi

Differential Revision: D62377757

Pulled By: cortinico

fbshipit-source-id: 9e3fa3777b4e6e4d3f2eb0f996ac0ac7676eedbe
2024-09-09 07:22:28 -07:00
Nicola Corti d0a5f8ff51 Gradle to 8.10 (#46369)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46369

This bumps Gradle to the latest stable ahead of the 0.76 branch cut.

Changelog:
[Android] [Changed] - Gradle to 8.10

Reviewed By: tdn120, Abbondanzo

Differential Revision: D62296898

fbshipit-source-id: 59fc119dd6fad3b6b0ebbfcd8166da4cad9b8633
2024-09-06 09:28:13 -07:00
Nicola Corti 55d35411ae Finalize AssertJ migration (#46097)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46097

I've noticed we still have some tests here and there that were not migrated to AssertJ. This finishes them all.

Changelog:
[Internal] [Changed] - Finalize AssertJ migration

Reviewed By: javache

Differential Revision: D61473682

fbshipit-source-id: 3d51bfeb0e5ba3fd8cd4f3667dc88de3d88a3dbc
2024-08-19 10:51:24 -07:00
Nicola Corti db80d78d7a Merge all the remaining .so libraries into libreactnative.so (#46059)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46059

This merges all the remaining dynamic libraries into libreactnative.so.
Sadly I couldn't split this in smaller diffs as all the libraries are connected with each other.

I also had to introduce 2 other SOs: `libhermestooling.so` and `libjsctooling.so` which contains
all the necessary libs used when loading either JSC or Hermes. They need to be isolated
as RNGP will remove those libraries based on the library the user decides to pick.

Changelog:
[Android] [Breaking] - Merge all the remaining .so libraries into libreactnative.so

Reviewed By: hezi

Differential Revision: D61376496

fbshipit-source-id: ab9e725b7acbebdfd8fa3ff36ad34d080044bf0e
2024-08-16 05:42:46 -07:00
Antony M. Kithinzi 491c3e9d76 chore: migrate GenerateCodegenArtifactsTaskTest to assertj (#45845)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

[INTERNAL] [CHANGED] - Migrated `packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt` to assertj.

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: hezi

Differential Revision: D60597025

Pulled By: cortinico

fbshipit-source-id: 4228b958c7b9e1506640b9ff217f098e2626ea81
2024-08-02 04:08:08 -07:00