【问题标题】:React-native 0.65 (targetSdk=30) android build is failing because of react-native-reanimatedReact-native 0.65 (targetSdk=30) android build 由于 react-native-reanimated 而失败
【发布时间】:2021-10-10 07:21:47
【问题描述】:

我已经将 react-native 从版本 0.64.1 升级到 0.65.0-rc.3,因为需要 targetSdk=30 从 8 月 21 日起将捆绑包发布到 Google Play。我正在使用 upgrade helper 升级字母到字母现在我得到了./gradlew bundleRelease 错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseAssets'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
   > Failed to transform react-native-reanimated-65-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-assets}.
      > Execution failed for JetifyTransform: MyApp/node_modules/react-native-reanimated/android/react-native-reanimated-65-jsc.aar.
         > Transform's input file does not exist: MyApp/node_modules/react-native-reanimated/android/react-native-reanimated-65-jsc.aar. (See https://issuetracker.google.com/issues/158753935)

已经试过了:

  • 删除 node_modules,重新安装
  • 清理 gradle、项目、纱线缓存等...
  • 试图显式喷射
  • 升级安卓工作室
  • 将 react-native-reanimated 升级到最新版本

由于没有稳定的 react-native 版本来满足 Google 的要求,他们花了几个小时感到沮丧。有什么想法让它发挥作用吗?

----- 编辑----

作为一种临时解决方法,只需更改项目级 gradle 文件中的版本即可:

ext {
  buildToolsVersion = "30.0.2"
  minSdkVersion = 21
  compileSdkVersion = 30
  targetSdkVersion = 30
  ndkVersion = "20.1.5948944"
}

【问题讨论】:

  • 请分享您的错误日志
  • @AftabAmin 你可以在这篇文章中看到上面的日志。或者你的意思有什么不同?
  • @matusalem 您能否在真实设备中测试您的解决方案?
  • @olegario 当然,我已经将我的更新发布到了 Google Play Alpha 通道并且它正在工作。
  • 我遇到了同样的错误,我只是按照文档docs.swmansion.com/react-native-reanimated/docs/fundamentals/…

标签: android react-native build react-navigation react-native-reanimated-v2


【解决方案1】:

我刚刚升级到 RN 0.65 stable 并且在 Android 上遇到了同样的错误。我认为这是因为如果你想使用 react-native-reanimated 包 v2.0 升级有点早。他们可能还没有将 Android 升级到 RN 0.65。查看使用 RN Reanimated v. 2.0 的 RN 0.64-rc.1 早期升级者发生的类似问题:https://github.com/software-mansion/react-native-reanimated/issues/1486。我们需要等待 RN Reanimated 升级他们的库。

编辑:这里是 RN Reanimated incompatibility with RN 0.65 issue on Github 的链接:https://github.com/software-mansion/react-native-reanimated/issues/2290。

编辑 2:可以确认升级到 RN Reanimated v.2.3.0-alpha.2 解决了这个问题,并且 Android 构建成功使用 RN 0.65。

【讨论】:

  • 感谢 github 问题链接,更新为 2.3.0-alpha.2 后,我的 android 构建现在成功,同时使用 react-native 0.65.0
  • 请分享您的 podfile。我无法构建 iOS
  • iOS 立即为我构建了 RN 0.65。我正在使用标准 RN 模板 Podfile:github.com/facebook/react-native/blob/main/template/ios/Podfile.
【解决方案2】:

请确保这些模块与您的 package.json 中的编写方式完全相同,否则它将失败。我在 react-native-reanimated 上看到了很多原生发射器错误。

"react": "17.0.2",
"react-native": "0.65",
"react-native-reanimated": "^2.3.0-alpha.2",

删除旧的 npm 模块。然后运行yarn install。

我尝试使用 > yarn add react-native-reanimated@next 但构建失败。 我的最新版本在那个 package.json 上运行。我不太确定 IOS 版本。

我在 android 上的构建也成功地使用了这些依赖项。一路上我遇到了 npm 的问题,所以我切换到了 yarn。

我不知道为什么很多人都会出错,但我的即使使用 react native 的 rc3 也能正常工作。

"react-native": "0.65.0-rc.3",
"react-native-reanimated": "^2.3.0-alpha.2",

############################################## #################

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'Redmi Note 8 Pro - 11' for app:debug
Installed on 1 device.

BUILD SUCCESSFUL in 1m 40s
133 actionable tasks: 110 executed, 23 up-to-date
info Connecting to the development server...
info Starting the app...
Starting: Intent { cmp=com.myapp/.MainActivity }

【讨论】:

  • 您正在使用 reanimated 的 alpha 版本,其中包含对问题的修复。虽然它是一个 alpha 版本,所以大多数人都没有使用它。他们很可能仍在使用最新的稳定版(截至目前为 2.2)。
  • 好吧,正如我最近尝试过的那样,Native Emitter 问题实际上仍然存在于 alpha 上。我暂时停止了 RN,然后回去做出反应,直到他们释放出稳定的 RN; :)
【解决方案3】:

试试这个:

npm i react-native-reanimated@^1.13.2

【讨论】:

  • 与之前的贡献者建议的那样升级到Reanimated v.2.3.0-alpha.2 有什么好处?
【解决方案4】:

没有什么对我有用,所以我重新安装了较低版本的 RN,之前我使用的是 RN 0.65.1=>

npm install react-native@0.64.2

【讨论】:

    【解决方案5】:

    唯一与 react native v65 兼容的 reanimated 版本是 v2.3.0-alpha3。 Try This

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-05
      • 2021-11-27
      • 2021-11-25
      • 2022-11-17
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      • 2017-12-28
      相关资源
      最近更新 更多