React-Native: Android 编译过程中 gradle 依赖包下载各种下载不下来、下载超时、极慢下载的处理方案。

 报错提示如下

1、下载不下来、下载超时。 

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-safe-area-context'.
> Could not resolve all files for configuration ':react-native-safe-area-context:classpath'.
   > Could not download kotlin-compiler-embeddable-1.6.20.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.20)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.6.20/kotlin-compiler-embeddable-1.6.20.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.6.20/kotlin-compiler-embeddable-1.6.20.jar'.
            > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.108.215, repo.maven.apache.org/2a04:4e42:1a:0:0:0:0:215] failed: No route to host (connect failed)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 19m 54s
error Failed to install the app.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

 2、下载极慢,基本就是几KB的在慢慢下载。

<==========---> 81% CONFIGURING [9m 32s]
> :react-native-safe-area-context > Resolve files of :react-native-safe-area-context:classpath > kotlin-compiler-embeddable-1.6.20.jar > 4.8 MiB/49.5 MiB downloaded
^Z
zsh: suspended  yarn android

 解决方案

就以报错提示来看,提供的下载jar压缩包的链接,丢到浏览器也是很难下载的。

但是,我们可以换个仓库去下载

https://mvnrepository.com/

1、浏览器打开上面的链接

2、输入框搜索你下载不下来的依赖包包名,比如我这里是 kotlin-compiler-embeddable 

3、点进去查看详情

Google 和 Central 就是项目目录 android/build.gradle 里面的 google() 和 mavenCentral() 下载源。我们在这两个选项里面找到报错或者下载慢的版本进入详情。

4、找到对应的版本查看详情。这个网站Tab切换选中效果不明显,以标记出来了。

 5、点击这个位置下载 jar 压缩包。

6、打开文件夹进入下面的文件路径。默认是在这个路径下面,如果你没有这个路径,自行百度你的 gradle 依赖包存放位置。

/Users/你的电脑名/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable

因下载报错、或者下载慢,都会在  kotlin-compiler-embeddable 文件夹下有 1.6.20 的版本号文件夹,版本号文件夹下有类似 18f66cca4301c12893ebe4ef47d65c3d9d2bff9b 的文件夹。

进到这个一串字符串的文件夹,然后把刚刚下载下来的 jar 依赖包丢到里面去。

然后在项目目录下 重新执行 

yarn android

其他依赖包类似。注意包名!!!

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值