reactnativecn / react-native-website

React Native 中文网
https://reactnative.cn
MIT License
216 stars 327 forks source link

mac搭建RN环境问题 #665

Closed poisonfff closed 1 year ago

poisonfff commented 1 year ago

执行npx react-native doctor报错 Common ✓ Node.js ✓ yarn ✖ Watchman - Used for watching changes in the filesystem when in development mode

Android ✓ JDK ✓ Android Studio - Required for building and installing your app on Android ✖ Android SDK - Required for building and installing your app on Android

iOS ✓ Xcode - Required for building and installing your app on iOS ✓ CocoaPods - Required for installing iOS dependencies ● ios-deploy - Required for installing your app on a physical device with the CLI

poisonfff commented 1 year ago
Snipaste_2022-11-08_10-26-53

![Uploading Snipaste_2022-11-08_10-20-58.png…]()

poisonfff commented 1 year ago
Snipaste_2022-11-08_10-20-58
sunnylqm commented 1 year ago

缺什么补什么就行了,你这里缺

  1. android sdk,打开android studio安装
  2. ANDROID_HOME环境变量

总之文档步骤里应该都有啊?

poisonfff commented 1 year ago
Snipaste_2022-11-08_10-38-18 Snipaste_2022-11-08_10-38-34 Snipaste_2022-11-08_10-38-53
sunnylqm commented 1 year ago

装了就行,doctor的检查可以忽略

poisonfff commented 1 year ago
Snipaste_2022-11-08_10-41-29

包括环境变量也是按照官方文档来的 依然报错

sunnylqm commented 1 year ago

doctor 这个工具未必同步更新了,以文档为准

poisonfff commented 1 year ago
Snipaste_2022-11-08_10-43-58

但是项目跑不起来

sunnylqm commented 1 year ago

跑不起来就截跑不起来的图

poisonfff commented 1 year ago

帮忙看一下

Snipaste_2022-11-08_10-45-58 Snipaste_2022-11-08_10-46-12
sunnylqm commented 1 year ago

老项目是吧,置顶的问题看了吗

poisonfff commented 1 year ago

是的,老项目,不知您说的置顶问题是指的哪一个?

Snipaste_2022-11-08_11-06-04
sunnylqm commented 1 year ago
image

https://github.com/reactnativecn/react-native-website/issues/660

poisonfff commented 1 year ago

版本从0.64.3上升到0.64.4,并重新下载依赖

Snipaste_2022-11-08_12-01-46
sunnylqm commented 1 year ago

往下截图,上面的看不到具体报错

poisonfff commented 1 year ago
Snipaste_2022-11-08_12-45-24 Snipaste_2022-11-08_12-45-38
sunnylqm commented 1 year ago

你是不是自己创建了个buildConfig文件?是的话删掉 删掉后在android目录中运行 ./gradlew clean 再试试

poisonfff commented 1 year ago

如果,你是指的这个文件的话

Snipaste_2022-11-08_14-29-34

删除并执行命令后,启动项目

Snipaste_2022-11-08_14-31-49 Snipaste_2022-11-08_14-31-34
sunnylqm commented 1 year ago

不是在编译产生的build文件夹(灰色)中,要在你的源码文件夹(非灰色)中找到并删除

poisonfff commented 1 year ago

项目全局搜了一下,叫buildConfig的文件里面只有一个debug文件夹,应该不是您说的文件,源码里也没有

Snipaste_2022-11-08_14-56-44 Snipaste_2022-11-08_14-54-26
sunnylqm commented 1 year ago
image

这看命名就不是正常的文件啊

poisonfff commented 1 year ago

之前就是删的这3个文件,就是您说的灰色文件

sunnylqm commented 1 year ago

这几个文件不会凭空产生,一定是从源码产生

poisonfff commented 1 year ago

删除之后,进入android目录中运行 ./gradlew clean,再yarn react-native run-android,他只生成了一个BuildConfig.java文件, 还是报一小时前的错误

sunnylqm commented 1 year ago

一小时前的错误是什么错误,你上面截图里的错误只有这个几个BuildConfig,其他都只看到警告(不影响编译和运行)

poisonfff commented 1 year ago

请看

Snipaste_2022-11-08_15-40-43 Snipaste_2022-11-08_15-40-57 Snipaste_2022-11-08_15-41-09
sunnylqm commented 1 year ago

现在已经一切正常,编译也已完成

image

问题就是 No connected devices (链接手机,打开usd调试,或者创建一个模拟器)

poisonfff commented 1 year ago

电脑上有android studio,也连上了手机,有什么办法让他执行到手机上,而不是android studio的模拟器吗?

sunnylqm commented 1 year ago

https://reactnative.cn/docs/running-on-device

poisonfff commented 1 year ago
Snipaste_2022-11-08_16-58-27 Snipaste_2022-11-08_16-58-41
sunnylqm commented 1 year ago

这是从别的系统复制过来的项目吧,权限不对,你需要用 chmod 命令给这个 launchPackager.command 文件加上执行权限

sunnylqm commented 1 year ago

或者 rm -rf node_modules && yarn 重装

poisonfff commented 1 year ago

权限问题没有解决,但是我手动打开了那个文件,跳过了这个问题

Snipaste_2022-11-08_17-27-14
github-actions[bot] commented 1 year ago

👋 Hey there, it looks like there has been no activity on this issue in the last 90 days. Has the issue been fixed, or does it still require the community attention? This issue will be closed in the next 7 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

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.