Граф коммитов

69 Коммитов

Автор SHA1 Сообщение Дата
Nicola Corti c11785b90d Update the hermesc output to be inside the $buildDir
Summary:
Currently, we build Hermes by specifying the Cmake flag `-B ./hermes`. That means
that the output out the build is going to be placed along side the source code.

This is fine, as long as the user doesn't use the `REACT_NATIVE_OVERRIDE_HERMES_DIR`,
which is used inside the Hermes CI. In that case, the source location of Hermes can be
changed, leading to scenarios where `hermesc` can't be found.

Here I'm changing the flag to be `-B $buildDir/hermes`. Therefore the build output
will always be located within the `./ReactAndroid/hermes-engine/build` folder.
This is a more robust solution as the build output will be encapsulated within the
`build/` folder.

Changelog:i
[Internal] [Changed] - Update the hermesc output to be inside the $buildDir

Reviewed By: cipolleschi

Differential Revision: D35964402

fbshipit-source-id: aa7e0775b282897d5a99c1c46265884d19c5f289
2022-04-27 09:41:11 -07:00
Nicola Corti 6563c99c49 Honor the REACT_NATIVE_OVERRIDE_HERMES_DIR variable when searching for `hermesc`
Summary:
When searching for the `hermesc` path, we should also honor the `REACT_NATIVE_OVERRIDE_HERMES_DIR` variable.

Changelog:
[Internal] [Changed] - Honor the REACT_NATIVE_OVERRIDE_HERMES_DIR variable when searching for `hermesc`

Reviewed By: neildhar

Differential Revision: D35903601

fbshipit-source-id: 31e1255a558eece8cd84669861328db72e9ed17b
2022-04-25 12:15:41 -07:00
Nicola Corti aeac6ab677 Gradle: extend the algoritm to find hermesc paths.
Summary:
This diff extends the Gradle algo used to search for `hermesc`.
Currently we look into `node_modules/hermes-engine/%OS-BIN%/hermesc`

With this change the algo will look into:
- A user provided path to hermesc
- Built from source version of hermesc (for users of New Architecture)
- Bundled version of hermesc inside react-native
- hermesc from the hermes-engine NPM package

I've added tests for the new algo. I also realized our tests were broken
(since they stopped running on CI), I fixed them as well.

Changelog:
[Android] [Changed] - Gradle: extend the algoritm to find hermesc paths

Reviewed By: ShikaSD

Differential Revision: D35649911

fbshipit-source-id: d4bcbe06a6bfa8d98b91c1612fc28b300de91661
2022-04-21 07:19:28 -07:00
Krisztiaan 5d560ca99f fix: `cliPath` should handle absolute paths (#32983)
Summary:
Avoid breaking tools relying on absolute path for `cliPath`

## Changelog

[Android] [Fixed] - Enable cliPath to have an absolute path value

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

Test Plan:
declare `cliPath` from `expo`:
```groovy
cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
```
and run an android build

Reviewed By: ShikaSD

Differential Revision: D33843275

Pulled By: cortinico

fbshipit-source-id: 65f55a5e07a4ec0a6205d5f06f150377708c30cc
2022-03-15 09:24:22 -07:00
Nick c34ef5841c Fix: Android react.gradle VmCleanup when packaging as library (#33179)
Summary:
When packaging a react app as an android library with the enableVmCleanup flag not set to false, an error occurs since the "package${targetName}" task can not be found. This PR adds a simple null check, similar to what is being done for the sTask and mTask just below it to prevent the error.

## 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] [Fixed] - Fixes android build error when compiling as library

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

Test Plan:
Compile project as library (com.android.library), and should not trigger and error with these changes.

Would also like to have this fix cherry-pick'd to release 0.67 after merging.

Reviewed By: ShikaSD

Differential Revision: D34475934

Pulled By: cortinico

fbshipit-source-id: ce6ce43960c4b388c4b1da49a9a6e21fd3bf8e16
2022-03-08 13:35:28 -08:00
Gabriel Donadel Dall'Agnol 200488e87c build: Bump AGP to 7.1.1 and fix bundle inclusion in release mode (#33057)
Summary:
Upgrade Android Gradle to 7.1.0 on template and fix a bug where the bundle was not getting included when building the app in release mode

Closes https://github.com/facebook/react-native/issues/33002
Closes https://github.com/facebook/react-native/issues/33018
Closes https://github.com/facebook/react-native/issues/33046
Potentially fixes https://github.com/facebook/react-native/issues/33029

## Changelog

[Android] [Changed] - Bump AGP to 7.1.0 and fix bundle inclusion in release mode

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

Test Plan:
1. Run `./scripts/test-manual-e2e.sh`
2. Select `A new RN app using the template` and `Android`
3. Test app on the emulator
4. Open Android studio build the app using release variant
4. Check the release apk using Android studio "Analyze APK" tool and ensure the bundle is included

![image](https://user-images.githubusercontent.com/11707729/152700410-3bcb80b0-35b6-4bdc-bf57-98a42a29e5a6.png)

Reviewed By: ShikaSD

Differential Revision: D34076884

Pulled By: cortinico

fbshipit-source-id: da4392af37e08e22dbcafba38476fd712141474a
2022-02-21 06:23:31 -08:00
Muhammad Numan 4e947ecb2d fix: jvm 11 error message from ReactPlugin.kt and react.gradle (#33048)
Summary:
you can see discussion here: https://github.com/reactwg/react-native-releases/discussions/13#discussioncomment-2069527
we were getting this error message when we build Gradle with other than 11 JVM
```
> Task :react-native-gradle-plugin:compileJava FAILED
2 actionable tasks: 2 executed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-gradle-plugin:compileJava'.
> invalid source release: 11
```
this solution is suggested by mikehardy

after this PR, now the error is like this
```
**************************************************************************************************************

ERROR: requires JDK11 or higher.
Incompatible major version detected: '8'

**************************************************************************************************************
```

## 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] [Fixed] - jvm 11 error message

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

Test Plan: install other than 11 java version and just run `./scripts/test-manual-e2e.sh` this command at the root of RN repo than this error will appair `invalid source release: 11`

Reviewed By: ShikaSD

Differential Revision: D34110990

Pulled By: cortinico

fbshipit-source-id: c142a363c7cec0db65d5ab9da858fd25866c7c49
2022-02-09 10:23:27 -08:00
Nicola Corti 574a773f8f Do not remove libjscexecutor.so from release builds (#32932)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32932

As the title says, we dont' want to remove `libjscexecutor.so` when
baking release builds and having JSC enable as this leads to instacrashes.

Fixes #32928
Fixes #32927

Changelog:
[Android] [Fixed] - Do not remove libjscexecutor.so from release builds

Reviewed By: ShikaSD

Differential Revision: D33681932

fbshipit-source-id: 5b59fd1fb76c80c191198d65c916bbbd9232c75b
2022-01-20 04:20:14 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Janic Duplessis 20b0eba581 Static link for hermes-inspector (#32694)
Summary:
Follow up to https://github.com/facebook/react-native/issues/32683 to also link hermes-inspector statically.

## Changelog

[Android] [Fix] - Static link for hermes-inspector

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

Test Plan: Tested a clean build and made sure hermes-inspector.so doesn't exist anymore.

Reviewed By: cortinico

Differential Revision: D32791208

Pulled By: ShikaSD

fbshipit-source-id: 6076b263469b9e2c6176d488d13292d4f1731dcc
2021-12-13 07:48:39 -08:00
Janic Duplessis b2cf24f41c Make hermes-executor-common a static lib (#32683)
Summary:
I've been seeing a couple crashes related to missing hermes-executor-common.so, seems to happen on specific android versions, but can't repro. I investigated this so file more and noticed it is incorrectly linked as a static library here b8f415eb6c/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk (L20). There doesn't seem to be any reason for this to be a shared lib so I changed it to be compiled as a static lib.

## Changelog

[Android] [Fixed] - Make hermes-executor-common a static lib

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

Test Plan:
- Verify there is no more hermes-executor-common-{release,debug}.so
- Test locally in an app to make sure it build and run properly.
- Verify that the crash happening on play store pre-launch report doesn't happen anymore.

Reviewed By: ShikaSD

Differential Revision: D32754968

Pulled By: cortinico

fbshipit-source-id: cb57e2d81edb4cbdb1f003dab45c53e594a5a62a
2021-12-01 11:19:23 -08:00
Vojtech Novak 7366a866b3 chore: make CLI error message more descriptive (#32593)
Summary:
motivation: I have a custom setup and needed to provide `react.cliPath`. I mistakenly provided path to `react-native-community/cli` which resulted into JS bundle not being generated. This error message provides a little more detail.

## 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
-->

[General] [Changed] - Improved error message in react.gradle

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

Test Plan: I guess it's not needed in this case

Reviewed By: ShikaSD

Differential Revision: D32427929

Pulled By: cortinico

fbshipit-source-id: 2be340a8be15c8ec08873c0368a36b449c8b5030
2021-11-15 05:40:27 -08:00
Geraint White d2c10da5d5 Add bundleForVariant option (#32472)
Summary:
Ref https://github.com/facebook/react-native/pull/30606#issuecomment-948458552

## Changelog

[Android] [Added] - Add bundleForVariant option

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

Test Plan:
I added the following log into react.gradle and ran the Android build for my app:

```
println("bundleEnabled: ${targetName}, ${bundleForVariant(variant)}")
```

```
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}
```

Console output:

```
Reading env from: env/cve/live
bundleEnabled: CveDebug, false
bundleEnabled: CveRelease, true
bundleEnabled: CveLive, true
bundleEnabled: WhceDebug, false
bundleEnabled: WhceRelease, true
bundleEnabled: WhceLive, true
```

Reviewed By: cortinico, ryancat

Differential Revision: D31910406

Pulled By: ShikaSD

fbshipit-source-id: baca5efaddedddad15d974cc7bb8f3c2a4c4f35b
2021-10-26 04:59:16 -07:00
Geraint White 055ea9c7b7 Fix devDisabledInStaging not working with multiple productFlavors (#30606)
Summary:
Fixes https://github.com/facebook/react-native/issues/27052

Since react-native 0.62, the `devDisabledIn${buildType}` syntax has stopped working for apps with multiple `productFlavors`. This PR adds the `disableDevForVariant` lambda to allow dev mode to be disabled for different variants.

## 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] [Fixed] - Fix devDisabledIn not working with multiple productFlavors

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

Test Plan:
I added the following log into `react.gradle` and ran the Android build for my app:

```
println("devEnabled: ${targetName}, ${devEnabled}")
```

```
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleInLive: true,
    disableDevForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}
```

Console output:

```
Reading env from: env/cve/live
devEnabled: CveDebug, true
devEnabled: CveRelease, false
devEnabled: CveLive, false
devEnabled: WhceDebug, true
devEnabled: WhceRelease, false
devEnabled: WhceLive, false
```

Reviewed By: cortinico

Differential Revision: D31649977

Pulled By: ShikaSD

fbshipit-source-id: 520734314f4bca7608b8dca67c7c5ce0be6d31a5
2021-10-25 08:11:40 -07:00
Nicola Corti a2b5e4cd82 Fix enableVmCleanup not working for apps with product flavors. (#32422)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32422

While working on the NDK AGP Api I realized that the `enableVmCleanup` function,
that is supposed to cleanup the extra `.so` files from the final artifacts, is broken
for apps with variants. Specifically say for a `liteDebug` app it tries to search for `.so` files inside:

```
intermediates/stripped_native_libs/lite/debug/out/lib
```

while the `.so` files are located inside:

```
intermediates/stripped_native_libs/liteDebug/out/lib
```

I've fixed changing the token of the path from `targetPath` to `variant.name`

Changelog:
[Android] [Fixed] - Fix enableVmCleanup not working for apps with product flavors

Reviewed By: ShikaSD

Differential Revision: D31654704

fbshipit-source-id: 4af3478a3079ebcde4bd8e0c62bf4df7b6c75c0f
2021-10-18 04:34:43 -07:00
Geraint White 91adb761cf Add hermesFlagsForVariant and deleteDebugFilesForVariant (#32281)
Summary:
Ref https://github.com/facebook/react-native/issues/25601#issuecomment-510856047.

From https://github.com/facebook/react-native/pull/31040.

The `hermesFlagsRelease` option only works with the release build type, but not with other build types.

This PR allows hermes flags on a per variant basis to be specified using the `hermesFlagsForVariant` lambda.

It also allows the hermes debugger cleanup to be run on a per variant basis using the `deleteDebugFilesForVariant` lambda.

## 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] [Fixed] - Fix hermesFlags not working with multiple variants

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

Test Plan:
Set the following options in `android/app/build.gradle` and ensure warnings are hidden when running `./gradlew assembleRelease` and `./gradlew assembleLive`.

```
    hermesFlagsForVariant: {
        def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live') ? ['-w'] : []
    },
    deleteDebugFilesForVariant: {
        def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live')
    },
```

Reviewed By: cortinico

Differential Revision: D31234241

Pulled By: ShikaSD

fbshipit-source-id: 2cb3dd63adbcd023061076b5a3b262a87b470518
2021-10-13 12:50:25 -07:00
enniel 6f126740fa gradle vm cleanup fix (#32257)
Summary:
This patch remove unused .so files for reduce android .apk and .aab

## Changelog

- [Android] [Fixed] - Exclude unused .so files for reduce android .apk and .aab

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

Test Plan:
I have created a repository for testing:
https://github.com/enniel/react-native-invalid-build-example

That lines includes patch for fix bug:
f195ecdbea/android/app/react.gradle (L331-L385)

```sh
git clone https://github.com/enniel/react-native-invalid-build-example
cd react-native-invalid-build-example
npm i
```

debug, hermes disabled, without patch
```sh
git switch hermes-disabled-without-patch
npm run build:android:debug:apk
```
open android/app/build/outputs/apk/debug/app-debug.apk in android studio

![debug-hermes-disabled-without-patch](https://user-images.githubusercontent.com/19760944/134640636-1505cfa4-0be9-4bb8-8130-74af01ebfd94.png)

debug, hermes enabled, without patch
```sh
git switch hermes-enabled-without-patch
npm run build:android:debug:apk
```
open android/app/build/outputs/apk/debug/app-debug.apk in android studio

![debug-hermes-enabled-without-patch](https://user-images.githubusercontent.com/19760944/134640743-f5730fbe-433f-45eb-a87c-e0e2eadb056b.png)

debug, hermes disabled, with patch
```sh
git switch hermes-disabled-with-patch
npm run build:android:debug:apk
```
open android/app/build/outputs/apk/debug/app-debug.apk in android studio

![debug-hermes-disabled-with-patch](https://user-images.githubusercontent.com/19760944/134640895-36f294ae-36fb-40b7-a767-f6b421fdbabd.png)

debug, hermes enabled, with patch
```sh
git switch hermes-enabled-with-patch
npm run build:android:debug:apk
```
open android/app/build/outputs/apk/debug/app-debug.apk in android studio

![debug-hermes-enabled-with-patch](https://user-images.githubusercontent.com/19760944/134641040-f4f08755-5234-4567-849d-0b815d58bc15.png)

release, hermes disabled, without patch
```sh
git switch hermes-disabled-without-patch
npm run build:android:release:apk
```
open android/app/build/outputs/apk/release/app-release.apk in android studio

![release-hermes-disabled-without-patch](https://user-images.githubusercontent.com/19760944/134641255-da3ccc5f-91e2-4b12-b0b2-1590fa13e5ce.png)

release, hermes enabled, without patch
```sh
git switch hermes-enabled-without-patch
npm run build:android:release:apk
```
open android/app/build/outputs/apk/release/app-release.apk in android studio

![release-hermes-enabled-without-patch](https://user-images.githubusercontent.com/19760944/134641396-f2ca3178-4225-4de7-b1f7-b741edba1877.png)

release, hermes disabled, with patch
```sh
git switch hermes-disabled-with-patch
npm run build:android:release:apk
```
open android/app/build/outputs/apk/release/app-release.apk in android studio

![release-hermes-disabled-with-patch](https://user-images.githubusercontent.com/19760944/134641675-b967df44-af1b-4070-9f84-a2f029381a39.png)

release, hermes enabled, with patch
```sh
git switch hermes-enabled-with-patch
npm run build:android:release:apk
```
open android/app/build/outputs/apk/release/app-release.apk in android studio

![release-hermes-enabled-with-patch](https://user-images.githubusercontent.com/19760944/134641737-aa4a435a-1fe2-4107-8bbd-8dadda24aebd.png)

Reviewed By: cortinico

Differential Revision: D31167423

Pulled By: ShikaSD

fbshipit-source-id: 4026df818c57fa699526ca1c31c1d1a68d58baef
2021-09-27 06:54:32 -07:00
Vitaly Iegorov ce51b62494 Fixed Android cliPath Gradle configuration option for build.gradle (#31839)
Summary:
When using monorepo with react-native you need to provide `android/app/build.gradle` following params(`cliPath`):
```
project.ext.react = [
    root: "../../../../",
    cliPath: "../../../../node_modules/react-native/cli.js",
    entryFile: "...",
    hermesCommand: "../../../../node_modules/hermes-engine/%OS-BIN%/hermesc"
]
```

With latest react-native `0.64.2` version you will get:
```
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1
```

Debugging this issue showed that providing `cliPath` options ends up building wrong path to cli:
```
> Task :app:bundleReleaseJsAndAssets FAILED
node:internal/modules/cjs/loader:944
  throw err;
  ^

Error: Cannot find module '/node_modules/react-native/cli.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
    at Function.Module._load (node:internal/modules/cjs/loader:774:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
```

Changed `react.gradle` for proper File creation for `cliPath` to support this configuration option.

## Changelog

[Android] [Fixed] - Changed `react.gradle` `detectCliPath` function logic for `cliPath` case

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

Test Plan: Run `./gradlew assembleRelease` or `./gradlew assembleDebug`

Reviewed By: yungsters

Differential Revision: D30877674

Pulled By: sshic

fbshipit-source-id: 26b75f8d29bf26b01630dde576b9052d0b94d89e
2021-09-15 10:32:01 -07:00
Leon Kiefer 88f0676ae4 use correct gradle packageTask and asserts dir for android libraries (#32026)
Summary:
Fixes https://github.com/facebook/react-native/issues/29577 and https://github.com/react-native-community/upgrade-support/issues/93, when building an android library the package task has a different name, which was not handled correctly in the react.gradle file. The fix uses the existing `packageTask` variable which is correctly set for applications and libraries. This PR also copies the bundled js file into the correct assets directory, which is different from the assets directory of applications.

## 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] [Fixed] - Fixed Android library builds with react.gradle file

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

Test Plan: Tested with my android library build which includes the `react.gradle` file and the build succeeded.

Reviewed By: sshic, ShikaSD

Differential Revision: D30368771

Pulled By: cortinico

fbshipit-source-id: 8f0df8c4d0fa38d85f7c0b9af56d88799571191d
2021-08-23 11:38:46 -07:00
Dulmandakh 502b819049 find-node.sh supports Homebrew on M1 (#31622)
Summary:
Homebrew on M1 installs executable binaries in **/opt/homebrew/bin** (See https://brew.sh/2021/02/05/homebrew-3.0.0/), and FBReactNativeSpec.build is failing because it couldn't find node. This PR changes find-node.sh script to add /opt/homebrew/bin into $PATH.

The way **react.gradle** trying to execute node is not using user environment variables, but system defaults, so it couldn't find it. I removed node execution, and hard coded cli path in parity with iOS d1ab03235c/scripts/react-native-xcode.sh (L106)

Fixes https://github.com/facebook/react-native/issues/31621 https://github.com/facebook/react-native/issues/31592

## Changelog

[General] [Changed] - find-node.sh supports Homebrew on M1

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

Test Plan: On M1, create a RN project and it'll fail to build iOS app. Apply the patch, and build will succeed.

Reviewed By: ShikaSD

Differential Revision: D28808206

Pulled By: hramos

fbshipit-source-id: 8b313b6685462a15e67d99c61a0202d17fece1ec
2021-06-02 15:32:08 -07:00
Janic Duplessis 1a67dda668 Don't minify JS bundle by default when using hermes (#30496)
Summary:
Minification is not needed for hermes as it does all required optimisations on the bytecode. This is what facebook does internally for hermes bundles and I also validated by comparing the bytecode bundle size on a minified and non-minified bundle.

## Changelog

[General] [Changed] - Don't minify JS bundle by default when using hermes

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

Test Plan: Verified that the JS bundled generated on Android and iOS when using hermes is not minified by checking the generated JS file manually.

Reviewed By: rickhanlonii

Differential Revision: D25235195

Pulled By: cpojer

fbshipit-source-id: ad2131aab4dfd17ab53b6a5720ed0e2f1b09cca4
2020-12-01 17:17:06 -08:00
inokawa cf97c1f3bd Fix typo (#30330)
Summary:
Fix typo in comment

## 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
-->

[CATEGORY] [TYPE] - Message

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

Reviewed By: fkgozali

Differential Revision: D25062086

Pulled By: PeteTheHeat

fbshipit-source-id: 251bf1d4f4986f77ae72f7654796ae1d49c1863d
2020-11-18 12:13:24 -08:00
Tomoaki Imai 53f55001af Fix App Bundle/Release build missing index.android.bundle with gradle plugin 4.1.0+/gradle 6.5 (#30177)
Summary:
- This fix resolves https://github.com/facebook/react-native/issues/29398
- After updating gradle to 6.5+ and android gradle plugin to 4.1.0+(which is recommended in the latest Android Studio 4.1), Running `:app:assembleRelease` or `:app:bundleRelease` will not contain `index.android.bundle` in Apk/AAB. It will be included when the command executed twice.
<img width="949" alt="Screen Shot 2020-10-17 at 11 32 43 PM" src="https://user-images.githubusercontent.com/6277118/96360808-38165c00-10d5-11eb-8b6e-f098517a24c7.png">

- This is caused by the task ordering update introduced in gradle plugin 4.1.0+/gradle 6.5. `mergeResources` task runs before `currentAssetsCopyTask`(copying the bundle asset file to intermediate output directory) which causes generated Apk/AAB not including the bundle file.
- The fix ensures mergeResources task runs after currentAssetsCopyTask

## Changelog

[Android] [Fixed] - Fix App Bundle/Release build missing index.android.bundle with gradle plugin 4.1.0/gradle 6.5

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

Test Plan:
- Reproducible repository https://github.com/tomoima525/android_build_test_rn
  -  This project is generated with `create-react-native-app` and updated Gradle version to 6.5 and com.android.tools.build:gradle plugin to 4.1
- Run `./gradlew clean :app:assembleRelease` and `./gradlew clean :app:bundleRelease` => reproduces the issue
- After adding the fix above and run `./gradlew clean :app:assembleRelease` and `./gradlew clean :app:bundleRelease` => The issue is resolved

- Also confirmed the build works properly with android gradle plugin `3.5.3` and `gradle 6.2`(the default value of `create-react-native-app`)

Reviewed By: fkgozali

Differential Revision: D24551605

Pulled By: cpojer

fbshipit-source-id: b0effe2c6ea682748af185061af951e2f2bce722
2020-10-26 16:06:33 -07:00
Kevin Gozali e8c1eeeb06 codegen Gradle: introduce com.facebook.react.codegen plugin to replace architecture.gradle script
Summary:
Instead of applying configs from gradle scripts, this introduces a proper Gradle plugin to enable Codegen in an application or library project. In the build.gradle, one enables it by:

```
plugins {
    id("com.android.application")
    id("com.facebook.react.codegen") // <---
}

// ...

react { // <--- the new plugin extension
    enableCodegen = System.getenv("USE_CODEGEN")
    jsRootDir = file("$rootDir/RNTester")
    reactNativeRootDir = file("$rootDir")
}
```

The plugin supports `react` plugin extension as demonstrated above. Adding this:
* automatically generates all TurboModule Java files via react-native-codegen **before the `preBuild` Gradle task**
* automatically adds the files to the `android {}` project configuration
* is done per project (build.gradle)

This will be the foundation for future React Native gradle plugin beyond just for react-native-codegen.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23065685

fbshipit-source-id: 4ea67e48fab33b238c0973463cdb00de8cdadfcc
2020-08-12 11:12:43 -07:00
Kevin Gozali c085068d7b OSS Android: architecture.gradle base setup
Summary:
Introduced `architecture.gradle` that sets up pluggable build-time codegen steps for Gradle so that:
* Libraries, including core ReactAndroid, can produce the new architecture codegen (NativeModule **Java** specs in this diff) during build time
* Hosting app (e.g. RNTester) can produce its own set of codegen specs separately

**Please note that this is still work in progress, hence app templates have not been updated to use it yet.**

In order to activate this setup, the env variable `USE_CODEGEN=1` must be set. Eventually, this var will be removed from the logic.

With this change, RNTester:
* Will see all the generated specs populated in the Gradle build dir, which should be equivalent to the currently [**checked in version**](https://github.com/facebook/react-native/tree/master/ReactAndroid/src/main/java/com/facebook/fbreact/specs).
* The specs will compile, but **have not been validated** vs the existing NativeModule .java classes through out the core -- that will be the next step
* The specs are under `com.facebook.fbreact.specs.beta` namespace, which will be configurable in the future. `.beta` is added to avoid conflict with the existing files in the repo.

### Is this all we need to enable TurboModule in Android?
No. There are a few more pieces needed:
* C++ codegen output for JNI layer for each NativeModule spec
* The C++ module lookup for TurboModule Manager
* The JNI build setup in Gradle for these C++ output
* Toggle to enable TurboModule system in the entire app

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D22838581

fbshipit-source-id: d972e2fbb37bdbd3354e72b014fc8bb27a33b9ac
2020-07-31 19:04:54 -07:00
Mike Grabowski afdcdc760f Update react.gradle (#28776)
Summary:
Running `./gradlew assembleRelease` fails as the path to the CLI contains a new line at the end. We don't run this command in `debug` mode, hence it passed the testing. My bad.

Fixed, checked in both `debug` with `bundleInDebug: true` and `release`.

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

## Changelog

[INTERNAL] [ANDROID] - Fix `React.gradle` to build Android apps in production
Pull Request resolved: https://github.com/facebook/react-native/pull/28776

Test Plan: Running `./gradlew assembleRelease` works

Reviewed By: hramos

Differential Revision: D21287789

Pulled By: TheSavior

fbshipit-source-id: dc3ec8eef7a919b072b562d2bd455e2f704bc083
2020-04-28 14:45:18 -07:00
grabbou 992e0ce922 fix: do not throw on missing `cliPath`, use the default value (#28625)
Summary:
The `cliPath` has always been optional value and in fact, even had its default value hardcoded in the React gradle file.

In this PR, I am just taking use of it and remove throwing an error, which is going to be a really annoying breaking change.

## Changelog

[ANDROID] [INTERNAL] - Don't require `cliPath`
Pull Request resolved: https://github.com/facebook/react-native/pull/28625

Test Plan:
Run Android project, everything works.
Provide custom `cliPath`, it gets respected

Reviewed By: cpojer

Differential Revision: D21044222

Pulled By: TheSavior

fbshipit-source-id: 8029f988d92abb9f64f30e05932c0d407d0c997e
2020-04-15 11:19:45 -07:00
Will Holen 4305a291a9 Upgrade Hermes dependency to 0.5.0
Summary:
Use the latest published release of hermes-engine. Update RN to invoke `hermesc` instead of `hermes`.

Changelog: [Android] [Changed] - Upgraded to Hermes 0.5.0

allow-large-files

Reviewed By: mhorowitz

Differential Revision: D20998564

fbshipit-source-id: 4824e273bcb044029a5a7e9379f168d3da47da50
2020-04-13 19:48:23 -07:00
Kacper Wiszczuk f21b4eb571 imp: Remove unused `npx` reference (#28544)
Summary:
Recently we removed `npx` usage from `react-native-cli` flow. After checking usages in this repo I found unused reference.

## 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
-->

[Internal] [Removed] - Remove unused `npx` reference
Pull Request resolved: https://github.com/facebook/react-native/pull/28544

Test Plan: Tests pass

Reviewed By: cpojer

Differential Revision: D20873090

Pulled By: hramos

fbshipit-source-id: 12e05e9635a83f19439024766817e4599320af98
2020-04-06 12:21:57 -07:00
Ventsislav Dimitrov 0d1fb458ab fix: Android gradle config when bundling for release (#28415)
Summary:
This fix aims to address the issue when bundling an Android app for release and getting the error exhibited in https://github.com/facebook/react-native/issues/28002 which I also encountered myself.

The config was changed sometime in November 2019 (as part of https://github.com/facebook/react-native/issues/26940, commit a3b0804867) to be very opinionated when it comes to the use of `npx` which Gradle itself cannot find anyway (I have `npx` installed globally and it didn't pick it up).

Another issue that the use of `npx` creates is that Gradle should only ever use the currently installed react-native cli rather than a (possibly) higher version which may not always have backward compatibility.

The proposed change simply throws a more descriptive error rather than defaulting to a tool which may or may not exist on the machine, be it CI or a development environment. I've also modified the RNTester app to reflect the correct config implementation relative to the RNTester app itself.

In real projects, the config inside `android/app/build.gradle` should look similar to the following snippet:

```
project.ext.react = [
  cliPath: "$rootDir/../node_modules/react-native/cli.js",
  entryFile: "index.js"
];
```

## Changelog
[Android] [Fixed] - Gradle release config
Pull Request resolved: https://github.com/facebook/react-native/pull/28415

Test Plan:
- [x] Successfully bundled an Android release build with correct config
- [x] Works with RNTester app

Reviewed By: mdvacca

Differential Revision: D20714372

Pulled By: hramos

fbshipit-source-id: 4d66139249c6f840582a71a48c64e6a6595f7af0
2020-03-28 09:06:46 -07:00
Kacper Wiszczuk a3b0804867 fix: Bundle assets in monorepo (#26940)
Summary:
In monorepo environment, `metro` isn't able to resolve `react-native` because the path to it is hardcoded.

I've also added `packagingOptions` to RNTester to make Android builds work for me. Let me know if this is something that is only specific to my setup, and shouldn't be added.

## Changelog

[Android] [Fixed] - Fix `bundleReleaseJsAndAssets` in monorepo env
Pull Request resolved: https://github.com/facebook/react-native/pull/26940

Test Plan:
- [x] - Works in monorepo setup on MacOS
- [x] - Works with RNTester app

Differential Revision: D18323703

Pulled By: cpojer

fbshipit-source-id: b8eb15dfd8a32ae11fd862fc725af9cffea2cf96
2019-11-05 03:08:12 -08:00
Amit Davidi 5df204b82d Fix error with bundling task eval. when no gradle config is provided (#27101)
Summary:
Fix `react.gradle`'s handling of the case where a configuration isn't explicitly specified by the parent project - e.g. before importing to `build.gradle` files:

```groovy
apply plugin: 'com.android.application'

// Nothing to define:
// project.ext.react = [
// ]
apply from: "../../node_modules/react-native/react.gradle"
```

This is a _ridiculously_ subtle change but it is nevertheless important, as, combined with other groovy quirks, it can result in an overall misbehaviour of the build script.

### Source of the bug

Currently, when a react build config _isn't_ specified by the user, RN's `react.gradle` falls back to `[]` (i.e. in [this line](81a6b6ed3c/react.gradle (L8))). In groovy, `[]` stands for an empty _array_ (actually, an empty `ArrayList` instance). The config, however, is expected to have the nature of a `Map`.

### Effects of the bug

As a bottom line, whenever a configuration isn't specified, the evaluation of [the condition](81a6b6ed3c/react.gradle (L184)) as to whether the bundling task in question should be enabled, results in the following build-time exception:

```
FAILURE: Build failed with an exception.

* Where:
Script '/Users/...../node_modules/react-native/react.gradle' line: 179

* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:bundleDebugJsAndAssets'.
   > Could not find method enabled() for arguments [[]] on task ':app:bundleDebugJsAndAssets' of type org.gradle.api.tasks.Exec.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
```

I'm not much of a Groovy person, but while digging in, I've learned that it has the following odd attribute to it:
When accessing a non-existing property of an empty `ArrayList` in a bean-like fashion (i.e. as `array.property1` rather than `array.getProperty('property1')`), a new empty array is returned. This only holds true for _empty_ arrays, as illustrated by the following snippet:

```groovy
def emptyArr = []
def arr = [40, 2]

def result1 = (emptyArr.uninitializedProp == null)
println "$result1, ${emptyArr.uninitializedProp}" // ==> false, []"

def result2 = (arr.uninitializedProp == null) // ==> MissingPropertyException
println result2 // Never reached
```

While this whole scheme could be a bug, it's nonetheless effective in both the latest 2.x.x groovy version and in 2.1.0 (which is the oldest one that seems to be available for download nowadays). The point being is that its a behavior that's sticked.

Note that other evaluations of `config` properties (e.g. [lines 10-19](81a6b6ed3c/react.gradle (L10)))  in the script are not effected by this as they are initially only examined in a boolean form, rather than using a null comparison; "Lucky" for us, empty arrays evaluate to `false`.

### Fix

Simply fallback to a groovy map rather than an array whenever `config` hasn't been specified. Namely, initialize it to `[:]`, which results in a new `HashMap` instance, rather than `[]`.

### Workaround

Until effectively fixed, can be worked-around by explicitly setting config to an empty map before the react gradle script is imported by the user:
```groovy
apply plugin: 'com.android.application'
project.ext.react = [:]
apply from: "../../node_modules/react-native/react.gradle"
```

## Changelog

[Android] [Fixed] - Fix 'Could not create task ':app:bundleDebugJsAndAssets'.' error in project with no react config
Pull Request resolved: https://github.com/facebook/react-native/pull/27101

Test Plan: Mostly regression is required here. I've myself ran this over a project with an empty config and the app has launched successfully in both `release` and `debug` flavors.

Differential Revision: D18298542

Pulled By: cpojer

fbshipit-source-id: 88b4715b75f190003c4813e5324a5094a7779f67
2019-11-04 08:17:06 -08:00
Andres Suarez 722feeb02b Tidy up license headers [1/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952695

fbshipit-source-id: 81aa607612ba1357ef7814ef20371335151afe7e
2019-10-16 10:06:33 -07:00
Maksym Rusynyk a0d8740878 Android template: Allow overriding default "index.js" entry file (#26769)
Summary:
- Using "System.getenv" allows to specify any entry file using environment variables and without modifying gradle file. Example:

    export ENTRY_FILE="another_entry_file.js"
    ./gradlew assembleDebug

- This functionality is also more align with iOS implementation that uses 'if [[ "$ENTRY_FILE" ]]; then'. See https://github.com/facebook/react-native/pull/23667 for more details.

- Possibility to define entry file on CI without modifying sources (Example: project like [pixels-catcher](https://www.npmjs.com/package/pixels-catcher) requires different entry file)

## Changelog:

[Android] [Added]  - Custom entry file on android using `ENTRY_FILE` environment variable
Pull Request resolved: https://github.com/facebook/react-native/pull/26769

Test Plan:
- Create a project from template

- Define `ENTRY_FILE` environment variable

```
export ENTRY_FILE="anotherIndexFile.js"
```

- Build android

```
./gradlew assembleDebug
```

Expected result: App contains bundle file that starts from `anotherIndexFile.js` file.

Differential Revision: D17903165

Pulled By: cpojer

fbshipit-source-id: 6b7cdf229918d101c170aa5fbdca6f3ef293d41c
2019-10-13 23:41:15 -07:00
Ilia Burdukovski 81a6b6ed3c fix build with hermes on windows (#26556)
Summary:
On the Windows platform, with hermes-engine enabled, the assembly crashes with an error:
![image](https://user-images.githubusercontent.com/8634793/65568495-ab11d980-df8c-11e9-83a0-2a2d26447860.png)
The problem lies in calling hermes command without the leading arguments `"cmd", "/c"` ([react.gradle, line: 152](e028ac7af2/react.gradle (L152)) )

## Changelog

[General] [Fixed] - Added a platform check and running commandLine with the corresponding arguments
Pull Request resolved: https://github.com/facebook/react-native/pull/26556

Test Plan:
Under Windows, enable hermes-engine in _build.gradle_ and run the `gradlew assembleRelease` or `gradlew bundleRelease` command
Also check assembly on other available platforms

Differential Revision: D17587023

Pulled By: cpojer

fbshipit-source-id: bab10213b23fac5ab6a46ac4929759dcd43e39c2
2019-09-25 17:51:48 -07:00
Jakob Krigovsky 9b0adb5ad1 Fix indentation in Gradle files (#26012)
Summary:
Fixes indentation in `*.gradle` files by using four-space indents [as specified in `.editorconfig`](0ccedf3964/.editorconfig (L13-L14)).

## Changelog

[Internal] [Fixed] - Fix indentation in Gradle files
Pull Request resolved: https://github.com/facebook/react-native/pull/26012

Test Plan: Considering [the diff consists of whitespace changes only](https://github.com/facebook/react-native/compare/master...sonicdoe:gradle-indentation?w=1), I think this is safe to merge if the test suite passes.

Differential Revision: D16761514

Pulled By: cpojer

fbshipit-source-id: 9b035b5c6b35a70b2b54fe35416840fb90a0c6b1
2019-08-12 02:45:57 -07:00
sunnylqm c21e36db45 Bump hermes to v0.1.1 (#25908)
Summary:
Hermes has been updated to [v0.1.1](https://github.com/facebook/hermes/releases/tag/v0.1.1) and [renamed from 'hermesvm' to 'hermes-engine'](c74842ee5c)

## Changelog

[Android] [Changed] - Bump hermes to v0.1.1
Pull Request resolved: https://github.com/facebook/react-native/pull/25908

Test Plan: RNTester builds and runs as expected

Differential Revision: D16645811

Pulled By: cpojer

fbshipit-source-id: 4fb6a3160df2c6d08140dd1fee51acf9ff8baffc
2019-08-05 12:58:25 -07:00
cpojer d7f5153cd8 Add Hermes support to React Native on Android (#25613)
Summary:
Yesterday we shipped hermesengine.dev as part of the current 0.60 release. This PR brings those changes to master.

## Changelog

[General] [Added] - Added support for Hermes
Pull Request resolved: https://github.com/facebook/react-native/pull/25613

Test Plan:
* CI is green both on GitHub and at FB
* Creating a new app from source can use Hermes on Android

Reviewed By: cpojer

Differential Revision: D16221777

Pulled By: willholen

fbshipit-source-id: aa6be10537863039cb666292465ba2e1d44b64ef
2019-07-25 23:05:53 -07:00
Robert Ying 58beaf02ec Fix regression of improper assets copy (revert #24518 #24778) (#25363)
Summary:
Pull requests https://github.com/facebook/react-native/issues/24518 #24778 make Gradle copy all **generated** assets and resources into `android/app/src/res`, which is a bad behavior, because `src/res` goes into version control and should hold only those **original** resource files.

These changes in https://github.com/facebook/react-native/issues/24518 #24778 were merged into 0.60.0-rc release and cause regression.

This pull request will:

- Revert pull requests https://github.com/facebook/react-native/issues/24518 #24778
- Close https://github.com/facebook/react-native/issues/25325

## Changelog

[Android] [Fixed] - Fix regression of improper assets copy (revert https://github.com/facebook/react-native/issues/24518 #24778)
Pull Request resolved: https://github.com/facebook/react-native/pull/25363

Test Plan: It is a revert pull request and the reverted script should work the same as it has in 0.59.x.

Differential Revision: D15963329

Pulled By: cpojer

fbshipit-source-id: 5619a318dbdb40e816e37b6e37d4fe32caa46e9e
2019-06-24 01:56:55 -07:00
Nate 995b4d3049 Android Fix for 9145: No longer hard code build port (#23616)
Summary:
### Problem

According to https://github.com/facebook/react-native/issues/9145, the `--port` setting is not respected when executing `react-native run-android`. The templates that report things like what port the dev server runs on are hard coded as well.

### Solution

This commit replaces the hardcoded instances of port 8081 on Android with a build configuration property. This allows setting of the port React Native Android connects to for the local build server.

For this change to work, there must also be an update to the react native CLI to pass along this setting:

https://github.com/react-native-community/react-native-cli/compare/master...nhunzaker:9145-android-no-port-hardcode-cli

To avoid some noise on their end, I figured I wouldn't submit a PR until it's this approach is deemed workable.

## Changelog

[Android][fixed] - `react-native run-android --port <x>` correctly connects to dev server and related error messages display the correct port
Pull Request resolved: https://github.com/facebook/react-native/pull/23616

Differential Revision: D15645200

Pulled By: cpojer

fbshipit-source-id: 3bdfd458b8ac3ec78290736c9ed0db2e5776ed46
2019-06-05 06:15:06 -07:00
Damien eb534bca58 Fix duplicate resource error in Android gradle build (#22234) (#24778)
Summary:
If `$buildDir/generated/res/react/${flavorPathSegment}release/raw` contains files during `gradle assembleRelease` script will fail with `Error: Duplicate resources` error.

This patch is based on this issue [22234](https://github.com/facebook/react-native/issues/22234) and pull request [24518](https://github.com/facebook/react-native/pull/24518).

[Android] [Fixed] - Fix duplicate resource error for raw folder in Android build

[CC from Mike Hardy PR]
Reports of success on the linked issue via use of the patch + patch-package for a couple months, I personally use it full time with all gradle builds (./gradlew clean assembleRelease or if you have a 'staging' flavor, e.g. ./gradlew clean assembleStagingRelease)

Related reading, also cross-links with the linked issue here:
https://stackoverflow.com/questions/53239705/react-native-error-duplicate-resources-android
Pull Request resolved: https://github.com/facebook/react-native/pull/24778

Differential Revision: D15277766

Pulled By: cpojer

fbshipit-source-id: 0ccd76d2aa2e13f7c8bfac07d4ef23b74945807a
2019-05-09 06:26:19 -07:00
Mike Hardy 962437fafd Fix duplicate resource error in Android gradle build (#22234) (#24518)
Summary:
Issue #22234 includes a number of people (myself included) suffering with duplicate resource errors while building in Android. We have been collectively using a patch there but I don't believe any attempt has been made to PR it upstream.

I am not excellent at gradle, so I may have approached this in completely the wrong way, but it works for me in the standard init templates, as well as my current work project which has a complicated 2 buildType + 4 productFlavor configuration. If there is a better way to achieve the result I am happy to learn

The approach here is to determine the generated path the resources land in, then move them into the main build output tree. If they remain in the generated path android merging fails with duplicate resource errors, so that move (vs copy) is important.

[Android] [Fixed] - Fix duplicate resource error in Android build
Pull Request resolved: https://github.com/facebook/react-native/pull/24518

Differential Revision: D15276981

Pulled By: cpojer

fbshipit-source-id: 3fe8c8556e4dcdac5f96a2d4658ac9b5d9b67379
2019-05-09 04:22:43 -07:00
Dulmandakh 30348f7899 bump android gradle plugin to 3.4.0 (#24463)
Summary:
This PR bumps Android Gradle Plugin to 3.4.0, which enables R8 shrinker by default and improves build performance significantly.

Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid.

[Android] [Changed] - bump Android Gradle plugin to 3.4.0
Pull Request resolved: https://github.com/facebook/react-native/pull/24463

Differential Revision: D15107117

Pulled By: hramos

fbshipit-source-id: 35a03dc9955e889c9399faeaf9a862e0fc044fc4
2019-04-27 09:43:19 -07:00
Héctor Ramos 7c9805ce16 Fix buildType issue introduced in rebase (#23444)
Summary:
While rebasing https://github.com/facebook/react-native/pull/18892, I missed that buildTypeName no longer existed.

[ANDROID] [Fixed] - Fix issue in react.gradle
Pull Request resolved: https://github.com/facebook/react-native/pull/23444

Differential Revision: D14078281

Pulled By: hramos

fbshipit-source-id: c2b3a1dccb890392f47ed93a3e1ac6e62e50999a
2019-02-13 19:08:27 -08:00
David Buchan-Swanson 6b21109d3d Allow bundle task to be disabled for release (#18892)
Summary:
The current system would always end up falling back to `true` for release builds
Pull Request resolved: https://github.com/facebook/react-native/pull/18892

Differential Revision: D14069444

Pulled By: hramos

fbshipit-source-id: 16e32a366b3b2e252a98a967da827ba1ebaeff85
2019-02-13 14:40:37 -08:00
Dulmandakh 8ccc55fbd3 Prepare Groovy scripts for Kotlin DSL migration (#23355)
Summary:
Using Kotlin DSL in Gradle instead of Groovy will help detect problems early on using static typing, and it has advanced IDE support. This PR prepares Groovy script for Kotlin DSL migration per **Migrating build logic from Groovy to Kotlin** guide. Here is the excerpt:

>As a first migration step, it is recommended to prepare your Groovy build scripts by
> - unifying quotes using double quotes,
> - disambiguating function invocations and property assignments (using respectively parentheses and assignment operator).

See: https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/

[Android] [Changed] - Prepare Gradle scripts for Kotlin DSL migration
Pull Request resolved: https://github.com/facebook/react-native/pull/23355

Differential Revision: D14018504

Pulled By: mdvacca

fbshipit-source-id: 909982c715b640f102cbe723df578c9af7bae08e
2019-02-09 10:18:07 -08:00
Michel dos Santos Kuguio 5be50d4820 - update to gradle 4.10.1 or high (#23103)
Summary:
Add suport to gradle 4.10.1 or high!
The new version of android studio 3.3 recommendete to update gradle project to 4.10.1

> To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin)

>Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio)

but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted

> WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.

> WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.

> WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.

> It will be removed at the end of 2019.
> For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.)
> To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.

Changelog:
----------
[Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high
Pull Request resolved: https://github.com/facebook/react-native/pull/23103

Differential Revision: D13817123

Pulled By: cpojer

fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 03:26:32 -08:00
Edward Karuna abfd563b47 Copy bundled resources and js in Android App Bundle builds (#21738)
Summary:
Android App Bundle builds use the packageBundle and bundle tasks instead
of the package and assemble tasks the APK builds use. Because of this,
the resources and js bundles weren't getting copied into the final
artifact. In an App Bundle build, the merged assets must be present
during the buildPreBundle step in order to arrive in the App Bundle.
Pull Request resolved: https://github.com/facebook/react-native/pull/21738

Differential Revision: D13669288

Pulled By: cpojer

fbshipit-source-id: 0e985983f04504b69e447dbc1f3f34cf8f4eb927
2019-01-15 02:15:28 -08:00
Christoph Nakazawa 63a6bb7637 Remove remaining references to local-cli
Summary: This removes the remaining references to `local-cli`. We already have a `cli.js` file on the root that was just forwarding to the local-cli folder, so I removed that. It also seems that `setupBabel.js` is no longer necessary in RN.

Reviewed By: TheSavior

Differential Revision: D13396218

fbshipit-source-id: a945cb91dae39c4b58c5cabcca6b0f0328fc4717
2018-12-10 19:08:10 -08:00
James Treanor c090758c12 Fix build error for Android projects that use `apply plugin: "com.android.library"` (#22312)
Summary:
This PR allows Android projects that use `apply plugin: "com.android.library"` to build successfully. A recent regression caused by https://github.com/facebook/react-native/pull/20526 means that building one of these projects always fails with this error:

```
FAILURE: Build failed with an exception.

* Where:
Script '/Users/james/src/SampleLibrary/node_modules/react-native/react.gradle' line: 15

* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'applicationVariants' for object of type com.android.build.gradle.LibraryExtension.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
```

This change updates `react.gradle` to cater to both application and library projects by selectively using `android.applicationVariants` or `android.libraryVariants`.

Fixes https://github.com/facebook/react-native/issues/22310.
Pull Request resolved: https://github.com/facebook/react-native/pull/22312

Differential Revision: D13373742

Pulled By: cpojer

fbshipit-source-id: 64c35ab7a6d5d0d840a43729123e70dd8e0d36e0
2018-12-06 20:33:11 -08:00