Skip to content

[Android] hermesV1Enabled flag ignored #55629

@farwayer

Description

@farwayer

Description

hermesV1Enabled flag in the project's gradle.properties is ignored for Android builds.

I added debug prints to node_modules/react-native/settings.gradle.kts

buildscript {
  val properties = java.util.Properties()
  val propertiesToInherit = listOf("hermesV1Enabled", "react.hermesV1Enabled")

  try {
    file("../../android/gradle.properties").inputStream().use { properties.load(it) }

    gradle.rootProject {
      propertiesToInherit.forEach { property ->
        println(properties.getProperty(property)) // false
        if (properties.containsKey(property)) {
          gradle.rootProject.extra.set(property, properties.getProperty(property))
        }
      }
    }
  } catch (e: Exception) {
    // fail silently
  }
}

and apparently the properties (tried both hermesV1Enabled and react.hermesV1Enabled) are being read correctly. But in the hermes assembly file node_modules/react-native/ReactAndroid/hermes-engine/build.gradle.kts the value is read as true:

val hermesV1Enabled =
    rootProject.extensions.getByType(PrivateReactExtension::class.java).hermesV1Enabled.get()
println(hermesV1Enabled) // true

Hardcoding the value in this file to false results in a build of a regular (non-V1) Hermes.

Steps to reproduce

  1. npx @react-native-community/cli@latest init test
  2. "resolutions": {"hermes-compiler": "0.15.0"} => package.json
  3. yarn
  4. hermesV1Enabled=false => android/gradle.settings
  5. add to android/settings.gradle
includeBuild('../node_modules/react-native') {
    dependencySubstitution {
        substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
        substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
        substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
        substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
    }
}
  1. yarn start & yarn android
  2. open debugger
  3. type HermesInternal.getRuntimeProperties()
Build:  "Release"
Builtins Frozen: false
Bytecode Version: 98
CommonJS Modules: "None"
Debugger Enabled: true
GC: "hades (concurrent)"
OSS Release Version: "for RN 0.84.0"
Static Hermes: true
VM Experiments:0

React Native Version

0.84.0

Affected Platforms

Runtime - Android, Build - Linux

Output of npx @react-native-community/cli info

System:
Binaries:
  Node:
    version: 25.6.1
    path: /usr/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/bin/yarn
  npm:
    version: 11.10.0
    path: /usr/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK:
    Android NDK: 27.1.12297006
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.18
    path: /usr/bin/javac
  Ruby:
    version: 3.4.8
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.1.0
    wanted: 20.1.0
  react:
    installed: 19.2.3
    wanted: 19.2.3
  react-native:
    installed: 0.84.0
    wanted: 0.84.0
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

-

MANDATORY Reproducer

https://github.com/farwayer/rn-bug-disable-hermesv1

Screenshots and Videos

No response

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