React Native工程运行时下载gradle超时问题

React Native工程在运行Android的时候会下载gradle,但是由于众所周知的问题,总是下载失败,这时可以通过修改 <APP_ROOT>/android/wrapper/gradle-wrapper.properties 文件中 distributionUrl 参数使用国内 gradle 镜像来提高下载速度。

下面是国内的两个镜像,可以找到自己需要的gradle版本,然后替换 <APP_ROOT>/android/wrapper/gradle-wrapper.properties 文件中 distributionUrl 参数。

比如,下面是我工程下 <APP_ROOT>/android/wrapper/gradle-wrapper.properties 文件原内容

shell 复制代码
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

修改后内容

shell 复制代码
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.6-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

然后重新运行 npm start。

相关推荐
木西2 小时前
React Native DApp 开发全栈实战·从 0 到 1 系列(流动性挖矿-前端部分)
react native·web3·智能合约
小妖怪的夏天5 小时前
react native 出现 FATAL EXCEPTION: OkHttp Dispatcher
react native·react.js·okhttp
qczg_wxg1 天前
高阶组件介绍
开发语言·javascript·react native·ecmascript
qczg_wxg3 天前
React Native的动画系统
javascript·react native·react.js
qczg_wxg3 天前
React Native常用的API
react native
Winson℡3 天前
在 React Native 层禁止 iOS 左滑返回(手势返回/手势退出)
react native·react.js·ios
卸任3 天前
从0到1搭建react-native自动更新(OTA和APK下载)
前端·react native·react.js
wayne2143 天前
「原生 + RN 混合工程」一条命令启动全攻略:解密 react-native.config.js
android·react native
qczg_wxg4 天前
ReactNative系统组件四
javascript·react native·react.js
木西6 天前
React Native DApp 开发全栈实战·从 0 到 1 系列(NFT交易-前端部分)
前端·react native