React-native: 'com.facebook.jni.CppException: Could not get BatchedBridge, make sure your bundle is packaged correctly ' error on signed apk when published on play store

Created on 20 Oct 2019  ·  10Comments  ·  Source: facebook/react-native

Most helpful comment

@olegwn Got it! Hermes active in release builds! For me it was very simple. I had the following in my dependencies. Though I'm unsure why it's only relevant to release builds but if either flavor of JSC is enabled that will cause the Hermes engine to fail. What ends up happening is all the view elements fail rendering.

So if you find either of the following libraries included as a dependency, remove them if you want Hermes to work.

if (useIntlJsc) {
        implementation 'org.webkit:android-jsc-intl:+'
} else {
        implementation 'org.webkit:android-jsc:+'
}

Additional Note:
I also have this rule in my proguard, though it didn't help with this issue.. Or maybe it did and that's why only debug builds ran...
-keep class com.facebook.hermes.unicode.** { *; }

For informational purposes, here is how I introduce Hermes into my React Native project. From /android/app/build.gradle:

project.ext.react = [
        entryFile: "index.js",
        enableHermes: true,  // clean and rebuild if changing
        hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes",
]

React Native had the following in app/build.gradle by default:
def enableHermes = project.ext.react.get("enableHermes", false)

Then my dependencies look like this:

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

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':_myLibrary')
}

My usage of JSC turned out to be in my project library, which was crashing release builds.

All 10 comments


We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

👉 Click here if you want to report a reproducible bug or regression in React Native.

@abolfazlyounesi were you able to solve this?
I am running into same issue and suggestions from 2016-2017 about not having 'adb' in the path -- are not helping

Same issues here! Could it be Hermes related? https://github.com/facebook/react-native/issues/26252

I have seen this issue in several conditions. All turned out to be my fault.
Here is the list (from memory)

  • Between RN 0.60 and 0.61 location of Hermes node_modules package changed. It needs to be correctly specified in your project (not app level) build.gradle. Check the RN template for detail.
    If not correct hermes shared lib will not be packaged, and will cause this error.

  • My project has React native web and React native, all built from the same tree.
    I had babel.config.js that was aliasing react-native-web to react-native, even for Android builds.
    this generate this silent problem

  • I had wrong appName in AppRegistry.registerComponent(appName, () => App); in the index file

  • the index file name did not match between android/app/build.gradle react project.react.ext.entryFile and getMainComponentName function override

Hi yes I solved the problem
I disabled Hermes and everything is ok after that

On Tue, Dec 17, 2019, 03:40 Daniel Tovar notifications@github.com wrote:

Same issues here! Could it be Hermes related? #26252
https://github.com/facebook/react-native/issues/26252


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/26930?email_source=notifications&email_token=AH4KH6Z42EDPINRGENSKQQDQZAKJBA5CNFSM4JCWC7OKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHATD3Q#issuecomment-566309358,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AH4KH64R4ZZVUI2FYSUR3QDQZAKJBANCNFSM4JCWC7OA
.

Hi yes I solved the problem I disabled Hermes and everything is ok after that

@abolfazlyounesi -- Yep, that was it. Thank you much! That was getting super frustrating. I'm almost certain I built a working release apk with Hermes enabled but who knows. Maybe I made some other change with proguard that was breaking Hermes on release builds.

Other methods that did NOT work:

  • node node_modules/react-native/local-cli/cli.js bundle --platform android --dev true --reset-cache --entry-file index.android.js
  • adb reverse tcp:8081 tcp:8081 adb
  • reverse tcp:8081 tcp:8081 inside Androidsdkplatform-tools
  • ./gradlew clean
  • manifest.xml and build.gradle changes

still encountering this at 0.61.5 :( any solutions? I want hermes enabled for release builds

@olegwn Got it! Hermes active in release builds! For me it was very simple. I had the following in my dependencies. Though I'm unsure why it's only relevant to release builds but if either flavor of JSC is enabled that will cause the Hermes engine to fail. What ends up happening is all the view elements fail rendering.

So if you find either of the following libraries included as a dependency, remove them if you want Hermes to work.

if (useIntlJsc) {
        implementation 'org.webkit:android-jsc-intl:+'
} else {
        implementation 'org.webkit:android-jsc:+'
}

Additional Note:
I also have this rule in my proguard, though it didn't help with this issue.. Or maybe it did and that's why only debug builds ran...
-keep class com.facebook.hermes.unicode.** { *; }

For informational purposes, here is how I introduce Hermes into my React Native project. From /android/app/build.gradle:

project.ext.react = [
        entryFile: "index.js",
        enableHermes: true,  // clean and rebuild if changing
        hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes",
]

React Native had the following in app/build.gradle by default:
def enableHermes = project.ext.react.get("enableHermes", false)

Then my dependencies look like this:

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

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':_myLibrary')
}

My usage of JSC turned out to be in my project library, which was crashing release builds.

@kevinbtesar Something out of what you did worked for me. I was trying to resolve this for hours. I think it had to do with removing:

if (useIntlJsc) {
        implementation 'org.webkit:android-jsc-intl:+'
} else {
        implementation 'org.webkit:android-jsc:+'
}

Thanks for the post!

@olegwn Got it! Hermes active in release builds! For me it was very simple. I had the following in my dependencies. Though I'm unsure why it's only relevant to release builds but if either flavor of JSC is enabled that will cause the Hermes engine to fail. What ends up happening is all the view elements fail rendering.

So if you find either of the following libraries included as a dependency, remove them if you want Hermes to work.

if (useIntlJsc) {
        implementation 'org.webkit:android-jsc-intl:+'
} else {
        implementation 'org.webkit:android-jsc:+'
}

Additional Note:
I also have this rule in my proguard, though it didn't help with this issue.. Or maybe it did and that's why only debug builds ran...
-keep class com.facebook.hermes.unicode.** { *; }

For informational purposes, here is how I introduce Hermes into my React Native project. From /android/app/build.gradle:

project.ext.react = [
        entryFile: "index.js",
        enableHermes: true,  // clean and rebuild if changing
        hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes",
]

React Native had the following in app/build.gradle by default:
def enableHermes = project.ext.react.get("enableHermes", false)

Then my dependencies look like this:

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

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':_myLibrary')
}

My usage of JSC turned out to be in my project library, which was crashing release builds.

Thank you so much!!! I can confirm that removing the useIntlJsc block fixed this for me. 👍

Was this page helpful?
0 / 5 - 0 ratings