React Native工程运行时下载gradle超时问题 - 6-all
React Native工程在运行Android的时候会下载gradle,但是由于众所周知的问题,总是下载失败,这时可以通过修改/android/wrapper/gradle-wrapper.properties 文件中 distributionUrl 参数使用国内 gradle 镜像来提高下载速度。
下面是国内的两个镜像,可以找到自己需要的gradle版本,然后替换/android/wrapper/gradle-wrapper.properties 文件中 distributionUrl 参数。
阿里云镜像:https://mirrors.aliyun.com/macports/distfiles/gradle/腾讯云镜像:https://mirrors.cloud.tencent.com/gradle/
比如,下面是我工程下/android/wrapper/gradle-wrapper.properties 文件原内容
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
修改后内容
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。
好文链接