Commit Graph

211 Commits

Author SHA1 Message Date
Nicola Corti dadf74fb68 Remove the enableSeparateBuildPerCPUArchitecture from the template entirely (#36341)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36341

See https://github.com/react-native-community/discussions-and-proposals/issues/602 for more context.
TL;DR: this flag is used for an edge case. We should not expose it to every users but move it to a guide.

I'll publish a guide on the website on how to achieve the same feature.

Changelog:
[Android] [Changed] - Remove the enableSeparateBuildPerCPUArchitecture from the template entirely

Reviewed By: cipolleschi

Differential Revision: D43695574

fbshipit-source-id: a4f2df755f1d7bd0319a8e418c4ce96b541009ed
2023-03-01 12:37:32 -08:00
Nicola Corti 81dd3afe0b Bump Gradle to 8.x (#36269)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36269

This bumps our project to build on Gradle 8.x
All the necessary issues have already been resolved so everything should be green.
Gradle version has been bumped also inside the template and RNGP.

Changelog:
[Android] [Changed] - Bump Gradle to 8.x

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D43534184

fbshipit-source-id: ca1fd6799ff6d776743de2b2d809fc54bc533440
2023-02-27 13:47:09 -08:00
Nicola Corti 8fae37eaea Flipper to 0.182.0 (#36221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36221

As the title says.

allow-large-files

Changelog:
[Android] [Changed] - Flipper to 0.182.0

Reviewed By: lblasa

Differential Revision: D43444516

fbshipit-source-id: 33c2cd4bdf98dc3f7037774003bfdfde2123d8cd
2023-02-21 00:30:16 -08:00
Nicola Corti 81e7f2fe91 Hardcode concurrentRootEnabled to true when Fabric is enabled (#36107)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36107

Having concurrentRoot disabled when Fabric is enabled is not recommended.
This simplifies the setup and makes sure that both are either enabled or disabled.

Changelog:
[Android] [Breaking] - Hardcode concurrentRootEnabled to true when Fabric is enabled

Reviewed By: cipolleschi

Differential Revision: D43127625

fbshipit-source-id: 88e5e800b55d5df228fb072bedf8533b0ab6c20d
2023-02-10 01:06:17 -08:00
Nicola Corti 5647d79dc9 RNGP - Bump AGP to 7.4.1 (#36039)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36039

This change bumps AGP to 7.4.1 so we can remove a lot of the unnecessary changes
we had to do to support AGP 7.3.x

I've also removed the explicit version in the template as now the AGP version
is provided by RNGP. That means that the user will get the correct version they need.

This also bumps the default CMake version in user space to 3.22 which resolves a lot
of warning when users are building with the New Architecture enabled.

Changelog:
[Android] [Changed] - Bump AGP to 7.4.1

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D42960353

fbshipit-source-id: 9065f975c1694d266a86b2d3fe805e6e2b1c4aa1
2023-02-02 07:07:45 -08:00
Frieder Bluemle efe5f62f91 Fix whitespace and newline at EOF (#35939)
Summary:
Just a couple of minor fixes in the `template/` folder:

- Remove a trailing space in `rn_edit_text_material.xml` (this was the _only_ trailing space present in a newly generated RN project), which results in the check against the empty tree object failing:
  ```
  $ git diff --check 4b825dc -- template/
  template/android/app/src/main/res/drawable/rn_edit_text_material.xml:23: trailing whitespace.
  +        <!--
  ```
- Add missing newline at end of file in `.watchmanconfig` and `app.json` - Both are text files, and each line (including the last) is expected to end with a newline character (flagged by Git, and also visible as a warning on GitHub):
  <img width="369" alt="image" src="https://user-images.githubusercontent.com/743291/214195867-81c8e622-2130-44d4-bdaf-588e3510c109.png">

## Changelog

[GENERAL] [FIXED] - Fix whitespace and newline at EOF in template

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

Reviewed By: christophpurrer

Differential Revision: D42698256

Pulled By: rshest

fbshipit-source-id: 765fd41d4f501aec578755c754ea0ecb290ae6ca
2023-01-24 03:00:08 -08:00
Nicola Corti 51a48d2e2c Remove unnecessary repositories{} block from top level build.gradle (#35644)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35644

The `repositories{}` block in the top level build.gradle is not needed anymore
The React Native Gradle Plugin is taking care of it.
Users can still specify if they need to provide custom repositories.

Changelog:
[Android] [Changed] - Remove unnecessary repositories{} block from top level build.gradle

Reviewed By: cipolleschi

Differential Revision: D42033953

fbshipit-source-id: 8ec1c12147fae68302ab47c60045869c72d1812c
2022-12-14 11:25:57 -08:00
Nicola Corti 46ffeca3b0 De-bump AGP to 7.3.1 and do not use addGeneratedSourceDirectory (#35631)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35631

Fixes #35592
I'm de-bumping AGP from 7.4 to 7.3 as per #35592. There is no stable release
of AGP that is working fine with the `addGeneratedSourceDirectory` API for resources.
Here I'm reverting to use the older APIs.

Changelog:
[Internal] [Changed] - De-bump AGP to 7.3.1 and do not use `addGeneratedSourceDirectory`

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D42004813

fbshipit-source-id: f1a2b0f7c2233402749a3e4f3828be80111ad3a7
2022-12-14 03:33:58 -08:00
shivenmian b7a85b59b5 chore: renamed react-native-codegen to @react-native/codegen (#34804)
Summary:
Renamed react-native-codegen package to react-native/codegen and updated references, without changing the folder name; part of RFC480 (https://github.com/facebook/react-native/issues/34692). Follow-up from https://github.com/facebook/react-native/pull/34578

## Changelog

[General] [Changed] - Renamed react-native-codegen package to react-native/codegen and updated references

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Reviewed By: cortinico

Differential Revision: D39883584

Pulled By: hoxyq

fbshipit-source-id: 0ef384b75c6edd248b31e37b8f05f64b4d39ca6f
2022-11-28 08:28:51 -08:00
Nicola Corti 10a8f186eb Bump Gradle to 7.6 (#35481)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35481

The next stable of Gradle just landed. I'm bumping it then.

Changelog:
[Android] [Changed] - Bump Gradle to 7.6

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D41533430

fbshipit-source-id: 56f8ec3c491991730612aad100f6781fd67f260e
2022-11-28 02:14:35 -08:00
Ruslan Lesiutin 6f11b10a88 refactor(react-native-gradle-plugin): rename react-native-gradle-plugin to @react-native/gradle-plugin (#35480)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35480

Changelog:
[General][Changed] - rename react-native-gradle-plugin to react-native/gradle-plugin

Reviewed By: cipolleschi

Differential Revision: D41532746

fbshipit-source-id: 67b936a211ec8b91a2a96ca22145cbea94ba3e8c
2022-11-25 10:29:36 -08:00
Nicola Corti 4c5eb8dd2a Bump AGP to 7.4.x (#35456)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35456

Fixes #35439

There is a bug in AGP 7.3.x which is causing assets to don't be copied properly inside the
final artifact: issuetracker.google.com/issues/237421684
As AGP 7.4.x is really close to release (is in Beta5, should be released stable in the next weeks)
we should be fine by bumping to beta5.

This also requires a bump of RNGP

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

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D41519549

fbshipit-source-id: 60d568a3e49798a23f1d7bf4839ab58bd5549aba
2022-11-24 09:18:36 -08:00
Lorenzo Blasa db3ac93001 Bump Flipper to 0.174.0 (#35445)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35445

As Flipper version is a bit old, let's bump it to the latest stable: 0.174.0.

This is a follow-up from D33583090 (https://github.com/facebook/react-native/commit/50057158ca32842d70160541e3cb5d4bd512f8f5).

At the time, it wasn't possible to update to the latest stable Flipper as crashes were observed due to NDK mismatch.

Changelog:
[Android] [Changed] - Bump Flipper to 0.174.0

Reviewed By: cortinico

Differential Revision: D41492705

fbshipit-source-id: 9ec205bb0b8e4ddcb56355a194cae0a64f3345d6
2022-11-24 07:46:00 -08:00
Nicola Corti 55b1670aa6 Void the Maven coordinates for react-native and hermes-engine (#35379)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35379

This diff moves the publishing coordinates from:
```
com.facebook.react:react-native
com.facebook.react:hermes-engine
```

to

```
com.facebook.react:react-android
com.facebook.react:hermes-android
```

I've picked those they are the most layout friendly when building from source, but we can discuss if we want others.
I've updated the Gradle plugin to have a dependencySubstitution rule + update the template with those changes.

It should now be possible to still use `implementation("com.facebook.react:react-native:+")` inside libraries
on 0.71+ and RNGP will resolve dependencies correctly.

Changelog:
[Android] [Changed] - Void the Maven coordinates for react-native and hermes-engine

Reviewed By: cipolleschi

Differential Revision: D41380525

fbshipit-source-id: 91e059fa261acb89bee7ca0c79c30c3d856a2c80
2022-11-18 04:46:16 -08:00
Oleksandr Melnykov 394486eec5 Bump OSS Android build to SDK 33 (#35196)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35196

Changelog:
[Android][Changed] - Bump Android compile and target SDK to 33

Reviewed By: cortinico

Differential Revision: D41007003

fbshipit-source-id: e7866107fdcfafa778faa6c7f31835b8dd15647a
2022-11-08 19:12:02 -08:00
Thibault Malbranche 38e35df47c chore: fix typo in build.gradle (#35209)
Summary:
## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - fixed typo in template build.gradle

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

Reviewed By: cipolleschi

Differential Revision: D41080347

Pulled By: cortinico

fbshipit-source-id: d2e36f232f798a636f98843edbc5651730125fc4
2022-11-07 06:30:33 -08:00
Nicola Corti cec9a34f6c Sets the namespace via Gradle and not via AndroidManifest (#35094)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35094

Currently the build on console is firing this warning:
```
> Task :app:processDebugMainManifest
package="com.androidtemplateproject" found in source AndroidManifest.xml: /tmp/AndroidTemplateProject/android/app/src/main/AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
```

This diff fixes it so users won't see it anymore on 0.71

Changelog:
[Android] [Fixed] - Sets the namespace via Gradle and not via AndroidManifest

Reviewed By: cipolleschi

Differential Revision: D40724654

fbshipit-source-id: 9b01748a22e9993b60e17bf25acbc68ba8e4eb77
2022-10-29 06:35:38 -07:00
Nicola Corti 6a43fafd78 Cleanup the template documentation after RNGP & hermesEnabled to gradle.properties (#35108)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35108

I've rewritten the comment in the android/app/build.gradle.
They were really old, contained wrong links and most of the people ignored it.

I've also moved the enabling of Hermes to the `gradle.properties` file.
RNGP still supports the old method, but we must be sure that we notify
library authors if they were reading project.ext.react.enableHermes in the past
(also the website needs to be updated).

I've also cleaned up the CircleCI setup as now we can specify Hermes enabled/disabled
via the CLI (this will also make easier to do e2e testing).

Changelog:
[Android] [Changed] - Cleanup the template documentation after RNGP & hermesEnabled to gradle.properties

Reviewed By: cipolleschi

Differential Revision: D40762872

fbshipit-source-id: 2c09245e0a923faac53cc6c8a89e99788ae47f8a
2022-10-27 14:40:27 -07:00
Nicola Corti 2097278d2a Update the template to load the correct JS engine at runtime. (#35095)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35095

This change will make sure that we load the correct JS engine at runtime,
by using the BuildConfig flag that RNGP sets for us.

This will solve a lot of noise in adb logcat for users seeing
stacktraces mentioning failing to load `jscexecutor` library.

This is also a breaking change, but as the API was not widely used nor
advertised in the template, we should be fine by just mentioning this in the release notes.

Changelog:
[Android] [Changed] - Update the template to load the correct JS engine at runtime

Reviewed By: cipolleschi

Differential Revision: D40710597

fbshipit-source-id: d59a7a52b22a9bf273ea89094c6620c3ecf6eb00
2022-10-27 04:47:25 -07:00
Nicola Corti 1f42ff0815 Bump AGP to 7.3.1 (#35100)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35100

That's just a minor bump of AGP before the branch cut.

Changelog:
[Android] [Changed] - Bump AGP to 7.3.1

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D40752006

fbshipit-source-id: 4856bc7ca275cf46d3afcc7c24928c5f1d5e6e33
2022-10-27 03:33:29 -07:00
Nicola Corti 07252b81f6 Do not import/use the deprecated ReactFlipperPlugin (#35099)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35099

I'm removing the ReactFlipperPlugin from the new app template.
That plugin is effectively empty and is a stub + is deprecated
so is generating a warning for all the users.

Changelog:
[Android] [Changed] - Do not import/use the deprecated ReactFlipperPlugin

Reviewed By: cipolleschi

Differential Revision: D40751984

fbshipit-source-id: 1f1fdf9c7dfccb9e7bbd4c8c2292df71e00c644f
2022-10-27 03:13:39 -07:00
Nicola Corti 1069841837 Make it easier for user to toggle only Fabric or TurboModules in New Architecture (#35091)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35091

This diff refines the DefaultNewArchitectureEntryPoint to make it easier for user to
either turn on Fabric, TurboModules or both.

Changelog:
[Internal] [Changed] - Make it easier for user to toggle only Fabric or TurboModules in New Architecture

Reviewed By: cipolleschi

Differential Revision: D40710596

fbshipit-source-id: 236060b2ebccb1bf25e7f5c0fc15f54c5ce5f608
2022-10-26 13:03:33 -07:00
Nicola Corti c96c76eb91 Update the template to use RNGP (#35075)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35075

This diff updates the New App template for Android to use the React Native Gradle Plugin.
With this we can:
1. Get rid of all the C++ code.
2. Remove a lot of New Architecture logic in the build.gradle
3. Reuse the prebuilts of React Native/Hermes via prefab

Changelog:
[Android] [Changed] - Update the template to use RNGP

Reviewed By: cipolleschi

Differential Revision: D40673732

fbshipit-source-id: 70935248993d1e24904c982e75f12ad580faa9d8
2022-10-25 13:13:14 -07:00
Nicola Corti 6a3bfa7a62 Bump NDK to 23 and fbjni to 0.3.0 (#35066)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35066

This just bumps the NDK version used inside the template to be 23.
We can't merge this as it is but we have to wait for a bump of the Docker image for Android.

Changelog:
[Android] [Changed] - Bump NDK to 23

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D40637103

fbshipit-source-id: e637140cbe6052e94a6efedf12f4b5b81b90a7eb
2022-10-25 02:31:10 -07:00
Nicola Corti 27cb501481 Cleanup BUCK files from template - Part 2 (#35020)
Summary:
The `template/android/app/build_defs.bzl` file can be removed as it's unused in the Template.

## Changelog

[Internal] - Remove build_defs.bzl from Android Template

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

Test Plan: n/a

Reviewed By: cipolleschi

Differential Revision: D40506250

Pulled By: cortinico

fbshipit-source-id: 14d8522a995a4b19b5b6610fcb2c5b1dda3374c8
2022-10-19 06:41:59 -07:00
Nicola Corti 32fc551c55 Cleanup Buck usages from New App Template (#34881)
Summary:
I'm cleaning up the Buck setup in the New App template. It hasn't been touched since 2018 and is currently not working, but will end up being propagated in user space.
This is also affecting the Gradle setup as there is a need to have an extra task just for Buck.

I doubt anyone is using this at this stage. We can get back to it or have a dedicated guide for users that are willing to use it.

## Changelog

[Android] [Remove] - Cleanup Buck usages from New App Template

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

Test Plan: Testing was missing on this API so there is nothing to test here

Reviewed By: cipolleschi

Differential Revision: D40142064

Pulled By: cortinico

fbshipit-source-id: 6c65e1030bf3fe1603bfb7d486f8f3fd7d254126
2022-10-12 03:21:12 -07:00
Nicola Corti 0b4417b43f Cleanup the template after prefab support (#34843)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34843

We can now remove a lot of unnecessary code to copy .so
files around as they're consumed via prefab from :ReactAndroid

Changelog:
[Android] [Changed] - Cleanup the Android template after prefab support

Reviewed By: cipolleschi

Differential Revision: D40014642

fbshipit-source-id: 00e69ea62bdb4882b40b8b6f19cdf80235c847b5
2022-10-04 03:27:07 -07:00
Nicola Corti 6d6d455618 Consume fbjni via Prefab (#34831)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34831

Historically we had to download an unzip the fbjni Android Archive to use it.
Here I'm updating the way how we consume to use prefab so we can remove a lot
of unnecessary configuration, also from the app template.

Changelog:
[Internal] [Changed] - Consume fbjni via Prefab

Reviewed By: cipolleschi

Differential Revision: D39964574

fbshipit-source-id: 1b18682c2b36aabb1fc1a3819ca09e575182eae4
2022-10-04 02:54:49 -07:00
Nicola Corti 49b14cc603 Move react_render_debug to be consumed via prefab (#34802)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34802

This removes the old way of consuming `libreact_render_debug.so` from
`Android-prebuilt.cmake` to using Prefab which is natively supported
by the Android pipeline.

Changelog:
[Internal] [Changed] - Move `react_render_debug` to be consumed via prefab

Reviewed By: cipolleschi

Differential Revision: D39849622

fbshipit-source-id: 45451dfe92ecce94d1b466094baae05a75ed803f
2022-09-27 09:30:50 -07:00
Ken Tominaga fb1f53f7dc misc: fix remaining NDK comment (#34769)
Summary:
Fix remaining NDK comment for new architecture

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Fixed] - Fix remaining NDK comment for new architecture

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

Reviewed By: cipolleschi

Differential Revision: D39762860

Pulled By: cortinico

fbshipit-source-id: 35a3c9fed58d32bd6dc16c0d6bb217a3c2849612
2022-09-23 06:30:02 -07:00
Nicola Corti 67bc498b24 Bump AGP to 7.3.0 inside the template (#34739)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34739

AGP 7.3.0 just got released which is glorious!
This allows us to remove a lot of unnecessary boilerplate to handle correct task ordering
inside the template

This requires "react-native-gradle-plugin" version 0.71.1 to be published on NPM.

Changelog:
[Android] [Changed] - Bump AGP to 7.3.0 inside the template

Reviewed By: mdvacca, dmytrorykun

Differential Revision: D39653419

fbshipit-source-id: 517363c952cbad2be0f2766c0a2b7daf3e75048b
2022-09-20 19:31:17 -07:00
Nicola Corti aba82a503d Update the OnLoad.cpp to use the facebook::react namespace
Summary:
Small follow up to my template update. Using the namespace in the OnLoad.cpp
should prevent name clashing and make it easier to read.

Changelog:
[Android] [Changed] - Update the OnLoad.cpp to use the facebook::react namespace

Reviewed By: cipolleschi

Differential Revision: D39475773

fbshipit-source-id: 9c0748d37858196d4e8ea6674d9cfd6ef4eff1cd
2022-09-14 04:06:53 -07:00
Nicola Corti 59ae0487ce Further simplify the New App Template by don't requiring the dynamic library name (#34671)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34671

I'm simplifying the template further by:
- Do not expose a configurable dynamic library name. Let's use `appmodules`
and still allow the users to configure it, if needed.
- Move all the initialization logic inside the `JNI_OnLoad` method
- Cleanup the `DefaultReactNativeHost` to don't require a dynamic library
name but just a boolean.

Changelog:
[Android] [Changed] - Further simplify the New App Template by don't requiring the dynamic library name

Reviewed By: cipolleschi

Differential Revision: D39462948

fbshipit-source-id: 737733fc263162a0baf3b7a451e48b8616679d3b
2022-09-13 06:42:37 -07:00
Nicola Corti b0aba1b6fa Update the New App template to reduce the amount of C++ code in user space (#34666)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34666

This diff updates the new app template and reduces the amount of C++ code in user space.
From now on users will have to only:
1. Create a CMakeLists.txt file
2. Create an OnLoad.cpp file with the Modules/Components they want to provide.

Changelog:
[Android] [Changed] - Update the template to Reduce the amount of C++ code in user space for New Architecture

Reviewed By: cipolleschi

Differential Revision: D39381762

fbshipit-source-id: 7309b6c61ba9ddd8856cb4aaa6d923ddd816741c
2022-09-12 12:48:43 -07:00
Jérémy Barbet ed21a3e20f fix(android): build.gradle typo (#34517)
Summary:
- Just a small typo fix

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Typo in build.gradle

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

Test Plan: - Check out the diff changes

Reviewed By: lunaleaps

Differential Revision: D39082272

Pulled By: cipolleschi

fbshipit-source-id: d62938d5a1e6802c6e7f44186adbbfa1a6715cf8
2022-08-27 22:31:06 -07:00
Tomek Zawadzki 50b1270298 Remove unused variable NODE_MODULES_DIR from build.gradle in app template (#34459)
Summary:
This PR removes unused variable `NODE_MODULES_DIR` passed from `build.gradle` to `CMakeLists.txt` which causes the following CMake warnings to appear in the logs:

```
> Task :app:configureCMakeDebug[arm64-v8a]
C/C++: debug|arm64-v8a :CMake Warning:
C/C++: debug|arm64-v8a :  Manually-specified variables were not used by the project:
C/C++: debug|arm64-v8a :    NODE_MODULES_DIR
```

First I changed the value of `NODE_MODULES_DIR` to some non-existent path (i.e. `-DNODE_MODULES_DIR=/foo/bar`) to confirm that the variable is indeed unused. Then I completely removed it from `arguments` and the CMake warning disappeared.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Removed unused variable `NODE_MODULES_DIR` from `build.gradle` in app template

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

Test Plan:
1. Create a new RN 0.70.0-rc.3 app from template with `npx react-native@next init RN070RC3 --version 0.70.0-rc.3`
2. Set `newArchEnabled=true` in `settings.gradle`
3. Open `android` directory in Android Studio
4. Run Gradle Sync
5. Build the app
6. Search for `NODE_MODULES_DIR` in the logs
7. Notice the CMake warning
8. Remove the line from this PR
9. Build the app again
10. Search for `NODE_MODULES_DIR` in the logs
11. Confirm there are no occurrences

Reviewed By: neildhar

Differential Revision: D38864127

Pulled By: cortinico

fbshipit-source-id: b41440edcdba63945e3b08cef897a250686c13ba
2022-08-19 08:12:01 -07:00
Nicola Corti dd6d5a78a3 Introduce the DefaultMainActivityDelegate to simplify enabling/disabling Fabric for new apps. (#34446)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34446

I'm adding another class to the .defaults package. This will take care of setting the RootView
with Fabric enabled/disabled as well as controlling concurrent root.

Changelog:
[Android] [Added] - Introduce the DefaultMainActivityDelegate to simplify enabling/disabling Fabric for new apps.

Reviewed By: cipolleschi

Differential Revision: D38823181

fbshipit-source-id: 2293b9df6b0d8fa79695bd52a8e0bb46b44c43c8
2022-08-18 07:30:23 -07:00
Nicola Corti 33bd2f6eae Simplify the template for New Architecture using the .defaults package (#34445)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34445

This commit simplifies the new app template by encapsulating a lot of configuration
by using the `DefaultReactNativeHost` from the .defaults package.

This should work for most of the users while still allowing advanced use cases
by using the good old ReactNativeHost.

Changelog:
[Android] [Changed] - Simplify the template for New Architecture using the .defaults package

Reviewed By: cipolleschi

Differential Revision: D38820111

fbshipit-source-id: 4e9529a92e1681610e3a1a89fdf82e6d10a18809
2022-08-18 03:35:23 -07:00
Nicola Corti dba6d565b3 Make sure the template project name is helloworld_appmodules (#34417)
Summary:
Make sure the new app template uses the correct project CMake project name: `helloworld_appmodules`, otherwise the app will fail to load the dynamic library.

This was a copy-n-paste error from RNTester.

## Changelog

[Internal] - Make sure the template project name is `helloworld_appmodules`

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

Test Plan: Will test an app created with the New App template

Reviewed By: cipolleschi

Differential Revision: D38698682

Pulled By: cortinico

fbshipit-source-id: b09331a52989b3b131ea8ba627057febcb535ef8
2022-08-15 02:42:03 -07:00
Nicola Corti 9214da1238 Do not load Flipper via reflection (#34383)
Summary:
Followup to https://github.com/facebook/react-native/issues/34379 by danilobuerger

Loading Flipper via reflection is type unsafe and requires extra code + exception handling that we can get rid of. The recommended way to use Flipper on Android is either via a `no-op` artifact or by using build flavors.

As we already had a setup for Flipper for `debug`, I'm creating the `release` equivalent which is just a stub. This allows us to get rid of some code inside `MainApplication.java`

## Changelog

[Android] [Changed] - Do not load Flipper via reflection

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

Test Plan: Will wait for a CI result on this.

Reviewed By: cipolleschi

Differential Revision: D38615257

Pulled By: cortinico

fbshipit-source-id: 66bb2c46c5df36a15c1b27512209a849f55d64c9
2022-08-11 05:10:39 -07:00
Danilo Bürger a379879adf Collapse catch blocks in template (#34379)
Summary:
Collapse catch blocks in template

## Changelog

[Android] [Changed] - Collapse catch blocks in template

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

Test Plan: No test plan required.

Reviewed By: cortinico

Differential Revision: D38593529

Pulled By: makovkastar

fbshipit-source-id: a26b00d88421f3e9201f98aabbc8a1b43159c208
2022-08-10 22:46:26 -07:00
Nicola Corti dfd7f70eff Update the new app template to use CMake instead of Android.mk (#34354)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34354

This change simplifies the setup for New Architecture for users on Android.
Instead of using the Android.mk file, users can now use a CMake file which
encapsulate a lot of the complexities and reduces the maintainance cost.

Android.mk support is kept for backward compatibility.

Changelog:
[Android] [Changed] - Update the new app template to use CMake instead of Android.mk

Reviewed By: cipolleschi

Differential Revision: D38460536

fbshipit-source-id: 9d4c3b15be751921d34023b24c174044537e6f02
2022-08-08 08:10:29 -07:00
Alexander Eggers 7a911e0730 Bump Gradle to 7.5.1 (#34359)
Summary:
https://github.com/facebook/react-native/pull/34310 introduced Gradle 7.5.0, but I noticed that the Gradle team actually missed to remove the `Incubating` annotation for the Java 18 support. The latest 7.5.1 is fixing that. More details can be found here: https://github.com/gradle/gradle/releases/tag/v7.5.1

## Changelog

[Android] [Changed] - Bump Gradle to 7.5.1

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

Test Plan: Successfully build on a local project. I can share the actual branch if needed.

Reviewed By: cipolleschi

Differential Revision: D38497804

Pulled By: cortinico

fbshipit-source-id: 792b83707d5b6aaf7ef29531f82a1bc9224b3204
2022-08-08 04:03:59 -07:00
LeoTM 5c8186623a Bump Gradle to 7.5.0 (#34310)
Summary:
### Follow-up
- https://github.com/facebook/react-native/issues/34103
- https://github.com/facebook/react-native/pull/33823

#### Debug/Release further tested on RN 0.70.0-rc.0-1
- https://github.com/leotm/react-native-template-new-architecture/pull/775
- builds/runtime: locally on `macos-13` b2
- builds: in CI `ubuntu-20.04` latest (not yet beta `ubuntu-22.04`)

cc cortinico dulmandakh

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Changed] - Bump Gradle to 7.5.0

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

Test Plan: Everything builds and runs as expected.

Reviewed By: cipolleschi

Differential Revision: D38311861

Pulled By: cortinico

fbshipit-source-id: c4e9e7a9052a067ffabae87204d20190ef46b351
2022-08-01 06:31:18 -07:00
Nicola Corti a22f30d2ce Fix missing import on New Architecture build script in template (#34230)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34230

The OS static class is accessed inside app/build.gradle but the import is on
the top level Gradle file. This is causing an app created from template to fail
building.

This is needed to be cherry-picked on the 0.70-stable branch.

Changelog:
[Android] [Fixed] - Fix missing import on New Architecture build script in template

Reviewed By: cipolleschi

Differential Revision: D37995897

fbshipit-source-id: aad22100cee004944c4fa0841f5ef0dfc6ea1e94
2022-07-20 07:08:33 -07:00
LeoTM 53c8fc9488 Bump AGP from 7.2.0 to 7.2.1 (#34166)
Summary:
- Fix: https://github.com/facebook/react-native/issues/34103
- Follow-up: https://github.com/facebook/react-native/pull/33817

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Changed] - Bump Android Gradle Plugin to 7.2.1

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

Test Plan: Everything builds and runs as expected

Reviewed By: javache

Differential Revision: D37747754

Pulled By: cortinico

fbshipit-source-id: b51f26d773ddfbdaf4490f89f3b207a41b225a82
2022-07-12 03:57:14 -07:00
Nicola Corti 7fb0bb40d2 Simplify the Android.mk file in the App Template (#34080)
Summary:
I'm simplifying the `Android.mk` file inside the template as it was confusing. There are two ways to include the generated code from the codegen:
1. Importing the generated Android.mk file
2. Include the generate source files in the `_appmodules` source files.

Those two approaches are mutually exclusive (as doing both will lead to duplicate symbols). Our template comments were confusing and were suggesting a combination of both.

I'm simplifying the comments here by removing the one suggesting to go with option `1` instead.

## Changelog

[Android][Changed] - Simplify the Android.mk file in the App Template

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

Test Plan: Nothing to test here as it's a comments only change

Reviewed By: cipolleschi

Differential Revision: D37463222

Pulled By: cortinico

fbshipit-source-id: 30ecc6fbbbcaf484272b4c724600cda588146506
2022-06-28 04:35:11 -07:00
Michał Pierzchała 9ad7cbc3eb Adapt template to new architecture autolinking on Android (#33777)
Summary:
Provides necessary changes for the autolinking to work in new architecture on Android. Depends on https://github.com/react-native-community/cli/pull/1603 and is subject to change.

Upgraded the RN CLI to v9.0.0-alpha.0 so that it's testable locally.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Change] - Adapt template to new architecture autolinking on Android

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

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D36478984

Pulled By: cortinico

fbshipit-source-id: 970fa7bcb77898d9defae18c20026a7783ba4108
2022-06-24 11:56:55 -07:00
Nicola Corti a7db8df207 Make Hermes the default engine on Android. (#34049)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34049

This just flips the switch for having Hermes on by default
on new projects for React Native.

Changelog:
[Android] [Changed] - Make Hermes the default engine on Android

Reviewed By: neildhar, jpporto

Differential Revision: D37354079

fbshipit-source-id: cb0391eb3927d13432e7d4b9efef7b8812938a98
2022-06-22 20:38:36 -07:00
Janic Duplessis 9ef30456c6 Pass string by ref in TurboModule template (#33970)
Summary:
https://github.com/facebook/react-native/commit/3337add547c60b84816ef5dad82f4ead2e8742ef made some changes to method signature but the template wasn't updated. This adds the missing changes.

## Changelog

[Internal] [Fixed] - Pass string by ref in TurboModule template

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

Test Plan: Didn't test the template directly, but the change is trivial.

Reviewed By: cortinico

Differential Revision: D36964481

Pulled By: dmitryrykun

fbshipit-source-id: 561e32f218baf398b8d4d8c77381a2642e22ef42
2022-06-07 04:37:45 -07:00