react native 项目中https://maven.google.com 连接不上的解决办法

react native运行报错Could not resolve com.google.android.gms:play-services-iid:[16.0.1]

在这里插入图片描述

google 自家的 maven 仓库 https://maven.google.com,连接不上。

1. 配置 Gradle Proxy,在 gradle.properties 中添加代理

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
systemProp.https.proxyUser=userid
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

2. dl.google.com 局域网可访问

https://maven.google.com 会 301 跳转到 https://dl.google.com/dl/android/maven2/

所以直接替换 https://maven.google.com 为 https://dl.google.com/dl/android/maven2/
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42998230/article/details/111309294