React-native: [0.61.2] Hermes does not support custom variants

Created on 21 Jan 2020  路  8Comments  路  Source: facebook/react-native


The logic in react.gradle relies on the variant name to contain release in order for Hermes to build properly.

Source 1 Source 2

In my case, I had a variant called staging. In order for hermes to work for me, I had to rename my variant to releasestaging. Instead, we should be able to pass required options in through app/build.gradle, without having to rename the variant.

React Native version:

System:
OS: macOS Mojave 10.14.6
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 2.35 GB / 32.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.18.1 - ~/.nvm/versions/node/v10.18.1/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v10.18.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 23, 26, 27, 28, 29
Build Tools: 27.0.3, 28.0.3, 29.0.2
System Images: android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2

Steps To Reproduce

  1. Create new React Native project
  2. Create custom variant that does _not_ include release in its name
  3. Enable hermes
  4. Build to device and see error when launching app:
couldn't find DSO to load: libhermes-executor-debug.so caused by: dlopen failed: cannot locate symbol "_ZTIN8facebook6hermes8debugger13EventObserverE" referenced by "/data/app/com.freeplay-q767SRYD9UinoTtLFqtR4Q==/lib/arm64/libhermes-inspector.so"...

Describe what you expected to happen:
Expect to build to device and the app to run successfully with Hermes enabled.

Snack, code example, screenshot, or link to a repository:
Example failing android/app/build.gradle. Replacing staging with releasestaging fixes the issue.

Related issue.

Bug Stale

Most helpful comment

The gradle hacks you refer to are also causing issues with hermes and the android gradle plugin v3.5. I'm not a gradle expert (I find their patterns hard to work with), but I think I've worked out how to improve this. But, it will take a few weeks for me to get to it. Stay tuned.

All 8 comments

The gradle hacks you refer to are also causing issues with hermes and the android gradle plugin v3.5. I'm not a gradle expert (I find their patterns hard to work with), but I think I've worked out how to improve this. But, it will take a few weeks for me to get to it. Stay tuned.

you need to add custom implementation on your '/app/build.gradle'

if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/"
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
        stagingImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }

'staginImplementaion' matches 'applicationIdSuffix' or 'buildTypes' on build config, im not sure, because my bad understanding in English, in my case I use same text on 'applicationIdSuffix' and 'buildTypes' so it works either way
as its mention here

https://developer.android.com/studio/build/dependencies#dependency_configurations

Alternatively, where there are targetName.toLowerCase().contains("release") checks, the gradle file could also honor the config."devDisabledIn${targetName}" setting.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

This is still a problem in 62.2.

I tried to make this work better, but I wasn't able to. If someone who is better at gradle than I am can submit a PR to improve this, that would be really helpful.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Was this page helpful?
0 / 5 - 0 ratings