根据官方文档进行初始化
- npm uninstall -g react-native-cli @react-native-community/cli(如果你之前全局安装过旧的react-native-cli命令行工具,请使用npm uninstall -g react-native-cli卸载掉它以避免一些冲突)
- npx @react-native-community/cli@latest init AwesomeProject
- cd AwesomeProject yarn react-native run-android
- Android Studio 环境已配好,但是我使用的是真机代替
初始化版本记录

报错1:

解决方法1:
下载对应的版本 gradle放到本地 distributionUrl替换成本地目录 distributionUrl=file:///D:/path/to/project/android/gradle/wrapper/gradle-8.10.2-all.zip
我使用的是rn是最新版本的0.76.3 ,默认的 gradle版本为 8.10.2 ,但是我下载对应版本的gradle后 报错
java.io.UncheckedIOException: Could not move temporary workspace
查询github后 gradle wrapper 升级到8.11 gradle/gradle#28475 (comment)
(还有有别的解决方法,希望大佬补充~)
报错2 Execution failed for task ‘:app:buildCMakeDebug[arm64-v8a]’.

解决方法: gradle.properties文件里面的 将“newArchEnabled=true”更改为“newArchEnabled=false”
每次执行失败都需要清除缓存,清除 android/.gradle android/.gradle/app/build 文件, 或者 cd android && ./gradlew clean
终于执行成功,真机设备成功显示 !T_T
npx react-native info
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.18363
CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
Memory: 9.11 GB / 31.84 GB
Binaries:
npm:
version: 9.8.1
path: D:\nvm\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "29"
- "30"
- "33"
- "34"
- "35"
Build Tools:
- 30.0.3
- 33.0.0
- 34.0.0
- 35.0.0
System Images:
- android-33 | Android Automotive with Google APIs Intel x86_64 Atom
- android-33 | Google Play Intel x86_64 Atom
- android-34 | Android TV Intel x86 Atom
- android-34 | Google TV Intel x86 Atom
- android-35 | Google Play Intel x86_64 Atom
- android-35 | Google APIs Experimental 16k Page Size Intel x86_64 Atom
- android-UpsideDownCakePrivacySandbox | Google Play Intel x86_64 Atom
- android-VanillaIceCream | Google Play Intel x86_64 Atom
Android NDK: Not Found
Windows SDK:
AllowAllTrustedApps: Enabled
IDEs:
Android Studio: AI-241.18034.62.2411.12071903
Visual Studio: Not Found
Languages:
Java: 17.0.12
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.3
wanted: 0.76.3
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

1990

被折叠的 条评论
为什么被折叠?



