Skip to content

RNTester doesn't build because it doens't seem to be included in settings.gradle.kts #36187

Closed
@ArthurAssuncao

Description

@ArthurAssuncao

Description

When I try to build RN-Tester with yarn install-android-jsc or yarn install-android-hermes, the build doesn't work, because rn-tester doesn't seem to be included in settings.gradle.kts.
This error doesn't occur in version 0.71.3.

The output with error of the yarn install-android-jsc below:

arthur@assuncao  ~/projects/react-native-test/react-native/packages/rn-tester   main  yarn install-android-jsc
yarn run v1.22.19
$ ../../gradlew :packages:rn-tester:android:app:installJscDebug
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Project directory '/home/arthur/projects/react-native-test/react-native/packages/rn-tester' is not part of the build defined by settings file '/home/arthur/projects/react-native-test/react-native/settings.gradle.kts'. If this is an unrelated build, it must have its own settings file.

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

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

BUILD FAILED in 8s
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I will send a PR that fixes this issue.

Version

main@{1day}...main - Latest version of code on github

Output of npx react-native info

Command was executed in rn-tester dir.

info Fetching system and libraries information...
System:
    OS: Linux 5.15 Manjaro Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-3612QM CPU @ 2.10GHz
    Memory: 4.14 GB / 11.59 GB
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 17.0.6 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Official steps for RN-Tester (RN-Tester Readme) for Running on Android.

  1. Clone the repository with git clone https://github.com/facebook/react-native.git and enter in react-native dir with cd react-native
  2. Install dependencies with yarn install
  3. Enter in rn-tester dir with cd packages/rn-tester
  4. Build with yarn install-android-jsc or yarn install-android-hermes

Snack, code example, screenshot, or link to a repository

The error seems to be in settings.gradle.kts, in this part of the code:

if (File("./packages").exists()) {
  include(":packages:rn-tester:android:app")
  // Include this to enable codegen Gradle plugin.
  includeBuild("packages/react-native-gradle-plugin/")
}

File("./packages").exists() is false when you're into rn-tester dir.
When I changed the code to (see below), it works (notice $rootDir).

if (File("${rootDir}/packages").exists()) {
  include(":packages:rn-tester:android:app")
  // Include this to enable codegen Gradle plugin.
  includeBuild("packages/react-native-gradle-plugin/")
}

After my changes, the output of yarn install-android-jsc is:

[... many of other tasks completed above]
> Task :packages:rn-tester:android:app:compileJscDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :packages:rn-tester:android:app:stripJscDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libicu_common.so.

> Task :packages:rn-tester:android:app:installJscDebug
Installing APK 'app-jsc-arm64-v8a-debug.apk' on 'ASUS_Z01KD - 8.0.0' for :packages:rn-tester:android:app:jsc-debug
Installed on 1 device.

BUILD SUCCESSFUL in 31m 53s
121 actionable tasks: 121 executed
Done in 1913.92s.

Version 0.71.3 works because it doesn't use conditional IF and it imported like this:

include(":ReactAndroid", ":ReactAndroid:hermes-engine", ":packages:rn-tester:android:app")

// Include this to enable codegen Gradle plugin.
includeBuild("packages/react-native-gradle-plugin/")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions