react-native艰难开发记录01

根据官方文档进行初始化

  • 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值