Skip to content

Android: latest release broke support custom react-native Root #804

@vladp

Description

@vladp

Environment

System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i
Memory: 15.44 GB
Binaries:
Node: 12.10.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.19.1 - C:\Users\v\AppData\Roaming\npm\yarn.CMD
npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
react: 16.9.0 => 16.9.0
react-native: ^0.61 => 0.61.2

Description

my directory structure is
andrapp\ <-- has android ./app , gradlew and so on
rn.common\ <-- has package.json index.android.js and ./node_modules

in react-native 60.6 I was able to specify the React native root (in app/build.gradle)


project.ext.react = [

        entryFile: "index.android.js",
        // whether to bundle JS and assets in debug mode
        bundleInDebug: false,
        // whether to bundle JS and assets in release mode
        bundleInRelease: true,
        bundleCommand: "ram-bundle",
        enableHermes: false,  // clean and rebuild if changing
        **root:** "${myRnAppRootDir_abs}"
]

And cli was able to correctly invoke
npx.cmd --quiet react-native config
from within rn.common directory

However since this change
5724d29#diff-375026a0607eb034a6fc70cca7d74689

native_modules.gradle
Now invokes npx in 'default' directly, not in React's project root. Which causes
npx.cmd --quiet react-native config
to complain with

error Unrecognized command "config".
info Run "react-native --help" to see a list of all available commands.

Which, then, causes JSON parsing error in native_modules.js

Here is code change in native_modules.js that causes the error on Android

// old code, that was working
cmdProcess = Runtime.getRuntime().exec(command, null, root)

// new code that does not work
cmdProcess = Runtime.getRuntime().exec(command)

From the design/documentation perspective, it seems that the whole infrastructure for getReactNativeProjectRoot() have been removed, and no alternative/migration documentation has been suggested.

Note also, that react-native 0.61 project template, continues to assert that configuring custom root (where package.json) resides, by specifying root in project.ext.react (in app/build.gradle) -- is still a valid and supported option

https://github.com/facebook/react-native/blob/master/template/android/app/build.gradle

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions