NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.3k stars 4.76k forks source link

为什么官方模板【React Native】总是跑不动?而且都没人提,难道只是我一个人的问题? #16086

Open xiaodeji opened 1 month ago

xiaodeji commented 1 month ago

相关平台

React Native

使用框架: React

复现步骤

直接通过taro init去创建一个【React Native】模板(源:GitHub),通过固定react版本小程序与H5能正常跑起来,而安卓环境一开始模拟器能正常启动,后面就开始不断报错了: Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 C:\Users\shuke\Desktop\demo\android\app\src\main\java\com\demo\MainActivity.java:2: ����: �����expo.modules������ import expo.modules.ReactActivityDelegateWrapper;

期望结果

官方【React Native】模板 安卓端,H5,小程序能正常跑起来

实际结果

安卓端跑不起来

环境信息

Taro CLI 3.6.33 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 18.20.3 - D:\nodejs\node.EXE
      Yarn: 1.22.22 - D:\nodejs\yarn.CMD
      npm: 10.7.0 - D:\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.33 => 3.6.33
      @tarojs/components: 3.6.33 => 3.6.33
      @tarojs/helper: 3.6.33 => 3.6.33
      @tarojs/plugin-framework-react: 3.6.33 => 3.6.33
      @tarojs/plugin-platform-alipay: 3.6.33 => 3.6.33
      @tarojs/plugin-platform-h5: 3.6.33 => 3.6.33
      @tarojs/plugin-platform-jd: 3.6.33 => 3.6.33
      @tarojs/plugin-platform-qq: 3.6.33 => 3.6.33
      @tarojs/plugin-platform-swan: 3.6.33 => 3.6.33
      @tarojs/plugin-platform-tt: 3.6.33 => 3.6.33
      @tarojs/plugin-platform-weapp: 3.6.33 => 3.6.33
      @tarojs/react: 3.6.33 => 3.6.33
      @tarojs/rn-runner: 3.6.33 => 3.6.33
      @tarojs/rn-supporter: 3.6.33 => 3.6.33
      @tarojs/runtime: 3.6.33 => 3.6.33
      @tarojs/runtime-rn: 3.6.33 => 3.6.33
      @tarojs/shared: 3.6.33 => 3.6.33
      @tarojs/taro: 3.6.33 => 3.6.33
      @tarojs/taro-loader: 3.6.33 => 3.6.33
      @tarojs/taro-rn: 3.6.33 => 3.6.33
      @tarojs/webpack5-runner: 3.6.33 => 3.6.33
      babel-preset-taro: 3.6.33 => 3.6.33
      eslint-config-taro: 3.6.33 => 3.6.33
      react: ~18.1.0 => 18.1.0
      react-native: ^0.70.1 => 0.70.15
wuweikd commented 1 month ago

我能跑,你先尝试使用纯React Native能不能跑。

xiaodeji commented 1 month ago

我能跑,你先尝试使用纯React Native能不能跑。

纯React Native能跑,就taro的不行

lixinlin commented 1 month ago

出错提示也是奇奇怪怪,很难定位问题

xiaodeji commented 1 month ago

出错提示也是奇奇怪怪,很难定位问题

是啊,好痛苦!弄个环境搞了好几天

hcw2175 commented 1 month ago

估计都搞鸿蒙去了

qph11kl commented 1 month ago

少安装了expo依赖

zhiqingchen commented 1 month ago

yarn upgradePeerdeps 有执行吗

25juan commented 1 month ago

https://juejin.cn/post/7375526202805420066 看一下我的这篇文章

lixinlin commented 1 month ago

按照上面文章的步骤执行完了初始化以及升级依赖,然后运行 build:rn,全新的项目,没有添加任何代码,报错如下: error Unable to resolve module ./src/pages/ucenter/index/index from xxxxxxxx\node_modules\@tarojs\rn-supporter\entry-file.js: None of these files exist:

执行了yarn cache clean问题依然存在

lixinlin commented 1 month ago

反复创建初始化了几次都是如此

lixinlin commented 1 month ago

选项: ? 请选择框架 React ? 是否需要使用 TypeScript ? No ? 请选择 CSS 预处理器(Sass/Less/Stylus) Less ? 请选择编译工具 Webpack5 ? 请选择包管理工具 yarn ? 请选择模板源 Github(最新) √ 拉取远程模板仓库成功! ? 请选择模板 react-native

lixinlin commented 1 month ago

\node_modules\@tarojs\rn-supporter\entry-file.js文件是空的,竟然会有引用错误

zhiqingchen commented 1 month ago

这个仓库有验证过初始化,可以跳过自己初始化,直接使用

https://github.com/zhiqingchen/taro-test/tree/tests/3.6.27

lixinlin commented 1 month ago

这个仓库clone下来以后build:rn没问题,过了,但是 run android 报错: FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

2: Task failed with an exception.