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。

相关推荐
早點睡3907 小时前
ReactNative项目Openharmony三方库集成实战:@react-native-ohos/react-native-image-picker
javascript·react native·react.js
弓.长.8 小时前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-fast-image — 高性能图片加载组件
react native·react.js·harmonyos
秋秋小事9 小时前
鸿蒙DevEvo Studio运行React Native生成的bundle文件遇到的一个问题
react native·react.js·鸿蒙
早點睡3909 小时前
ReactNative项目OpenHarmony三方库集成实战:react-native-linear-gradient-text
javascript·react native·react.js
Easonmax9 小时前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-image-picker — 图片选择器
react native·react.js·harmonyos
早點睡39010 小时前
ReactNative项目OpenHarmony三方库集成实战:@react-native-oh-tpl/react-native-fast-image
javascript·react native·react.js
早點睡39010 小时前
ReactNative项目OpenHarmony三方库集成实战:@react-native-oh-tpl/masked-view
javascript·react native·react.js
studyForMokey1 天前
【跨端技术ReactNative】JavaScript学习
android·javascript·学习·react native·react.js
Easonmax1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-pager-view — 流畅的页面滑动体验
react native·react.js·harmonyos
Easonmax1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-linear-gradient — 绚丽的渐变效果实现
react native·react.js·harmonyos