【问题标题】:Hermes is not working in Android with React-native 0.60.2Hermes 不适用于带有 React-native 0.60.2 的 Android
【发布时间】:2019-11-27 08:37:54
【问题描述】:

我已将现有(非新)项目中的 React-native 升级到 0.60.2,方法是更改​​ package.json,如此处所述https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.2

在 android/app/build.gradle 我放: p

roject.ext.react = [
    entryFile: "index.js",
    enableHermes: true  // clean and rebuild if changing
] 

构建成功,但 Hermes 似乎不起作用,在 RN 0.59.0 中,apk 为 29 Mb,现在为 46 Mb。

如果我像这里 https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.2 那样向 build.gradle 添加其他更改

然后我得到错误: 无法读取脚本“/Users/mac/Desktop/aqua2/node_modules/@react-native-community/cli-platform-android/native_modules.gradle”,因为它不存在。

可能是因为最后一行:

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

我该如何解决这个问题?

【问题讨论】:

  • @yevgen-pashutin 你找到解决方案了吗?我在一个新项目中面临同样的问题。 global.HermesInternal 好像是undefined
  • 我也收到了undefined,并按照build.graddle 的所有说明进行操作

标签: android react-native


【解决方案1】:

您应该为 applyNativeModulesAppBuildGradle 函数提供第二个参数。我从你的文件方向得到,你的根在上。这就是为什么我说你应该把你的根方向作为第二个参数。

  • 你的节点模块方向

    文件("../../node_modules/

  • 你应该这样做

    applyNativeModulesAppBuildGradle(项目,“../”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-09-27
    • 2020-03-25
    • 2017-06-08
    • 2020-11-29
    • 1970-01-01
    • 2022-01-11
    • 2021-08-13
    • 1970-01-01
    相关资源
    最近更新 更多