Skip to content

Conversation

@withSang
Copy link

Summary:

This PR removes the manual dependency configuration for Hermes/JSC in android/app/build.gradle.

Since React Native 0.71, the React Native Gradle Plugin (com.facebook.react) automatically manages the JS engine dependencies based on the hermesEnabled property in gradle.properties. The manual if (hermesEnabled.toBoolean()) block in the dependencies section is redundant and can be safely removed to simplify the build configuration.

Also, from React Native 0.83, hermes engine package name has been changed from com.facebook.react:hermes-android to com.facebook.hermes/hermes-android, making the manual if statement stale.

Changelog:

[ANDROID] [CHANGED] - Remove redundant Hermes/JSC dependency logic from build.gradle template

Test Plan:

  1. Initialize a new React Native project with these changes applied to the Android template.
  2. Ensure hermesEnabled=true is set in android/gradle.properties.
  3. Run ./gradlew app:dependencies inside the android folder.
  4. Verify that com.facebook.react:hermes-android (or com.facebook.hermes:hermes-android) is still listed in the dependency tree, confirming the plugin injected it automatically.
  5. Build and run the app on an Android emulator (npm run android).
  6. Verify the app launches successfully and the Metro bundler confirms "Engine: Hermes".

@cortinico
Copy link
Member

Since React Native 0.71, the React Native Gradle Plugin (com.facebook.react) automatically manages the JS engine dependencies based on the hermesEnabled property in gradle.properties. The manual if (hermesEnabled.toBoolean()) block in the dependencies section is redundant and can be safely removed to simplify the build configuration.

I don't think that's the case. Can you point to the line inside RNGP where this happens?

@withSang
Copy link
Author

Since React Native 0.71, the React Native Gradle Plugin (com.facebook.react) automatically manages the JS engine dependencies based on the hermesEnabled property in gradle.properties. The manual if (hermesEnabled.toBoolean()) block in the dependencies section is redundant and can be safely removed to simplify the build configuration.

I don't think that's the case. Can you point to the line inside RNGP where this happens?

Oh, I see. Sorry for causing the confusion.
I've read the RNGP codes again and just confirmed that implementation("com.facebook.hermes:hermes-android") is not generated by any plugin and still needed in the app template, but rather RNGP redirects the old hermes-android dependency(com.facebook.react:hermes-android) to the new one(com.facebook.hermes:hermes-android).

I've also discovered that the helloworld example app did so too.

I've edited the PR to address that. Thank you a lot!

@cortinico
Copy link
Member

I've edited the PR to address that. Thank you a lot!

I think we don't need the PR as is. What you're doing here is forcefully adding the hermes-android dependency for all the projects. However there could be users that don't use Hermes but use JSC so making this change will make it harder for those users to do so

@withSang
Copy link
Author

I've edited the PR to address that. Thank you a lot!

I think we don't need the PR as is. What you're doing here is forcefully adding the hermes-android dependency for all the projects. However there could be users that don't use Hermes but use JSC so making this change will make it harder for those users to do so

I see. What about just changing com.facebook.react:hermes-android to com.facebook.hermes:hermes-android? I've reverted the commits to do so

@cortinico
Copy link
Member

I see. What about just changing com.facebook.react:hermes-android to com.facebook.hermes:hermes-android? I've reverted the commits to do so

That is also unnecessary because RNGP will take care of it

@withSang
Copy link
Author

That is also unnecessary because RNGP will take care of it

While it's true that RNGP handles the substitution, the template should still be updated to use the correct com.facebook.hermes coordinates.
The template is the reference implementation for new apps. It should point to the actual artifact location (com.facebook.hermes) rather than relying on a compatibility shim designed for migration.
Also, if we keep the template on the old coordinates, we are setting up future projects to break whenever that compatibility logic is eventually removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants