7

I followed the official docs to enable the Hermes engine in my app but the following always returns false:

    const isHermes = () => !!global.HermesInternal;
    console.log('>>>>>>>>>>>>>', isHermes());

The changes I made are setting the following in android/app/build.gradle:

project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
]

Then I did a clean build with:

cd android && ./gradlew clean

yarn android

But the console.log always returns false

kimobrian254
  • 557
  • 3
  • 10
  • did your app show something like https://reactnative.dev/docs/assets/HermesApp.jpg on top right? – rishikesh_07 Sep 17 '20 at 12:24
  • This app has been in development for a while so that's not an option @rishikesh_07 . That's why I try to achieve something similar with the log – kimobrian254 Sep 17 '20 at 13:27
  • Can you make sure your apk contains all three of `libhermes.so`, `libhermes-inspector.so` and `libhermes-executor-debug.so`? Can you further make sure it does *not* contain JSC? [Here's the logic](https://github.com/facebook/react-native/blob/9b76e217bb16935069f0ea5b60f4c4d9b73f86d6/template/android/app/build.gradle#L205) that makes that happen in the RN template project. – that other guy Sep 17 '20 at 21:05
  • @thatotherguy How can I check that packages were properly installed in iOS case? – user1047504 Feb 13 '22 at 18:13

1 Answers1

0

I too got false when console.logging isHermes(). I realized it was because I was using the normal Chrome debugger(not sure of the internals of why). When I just console.logged in VSCode, I got true. There is a special way (sorry, my 'Copy link to highlight' isn't working, it's about 1/4 of the way down the page) you have to set up the Chrome debugger when you are using Hermes. There seems to be some trouble with getting it to work with newer versions of Chrome though. My plan right now to verify I'm actually using it is to compare the size of the binary before and after enabling Hermes.

gabriellend
  • 265
  • 2
  • 12