raw.githubusercontent.com 地址解析错误解决办法

背景

某个开源项目的build.gradle中,有一个github的raw源:

maven { url 'http://raw.github.com/saki4510t/libcommon/master/repository/' }

Android Studio编译时,出现DNS解析错误的问题。

错误描述

Unknown host '请求的名称有效,但是找不到请求的类型的数据。 (raw.githubusercontent.com)'. You may need to adjust the proxy settings in Gradle.
3: Task failed with an exception.
-----------
* What went wrong:
Could not resolve all files for configuration ':libuvccamera:debugCompileClasspath'.
> Could not resolve com.serenegiant:common:2.12.4.
  Required by:
      project :libuvccamera
   > Could not resolve com.serenegiant:common:2.12.4.
      > Could not get resource 'http://raw.github.com/saki4510t/libcommon/master/repository/com/serenegiant/common/2.12.4/common-2.12.4.pom'.
         > Could not HEAD 'http://raw.github.com/saki4510t/libcommon/master/repository/com/serenegiant/common/2.12.4/common-2.12.4.pom'.
            > raw.githubusercontent.com

尝试了科学上网法依然不能下载,看起来是被彻底屏蔽了。

问题原因

raw.githubusercontent.com是github的资源库,我们在github上存的库、图片、压缩包这类资源都是存在某处资源服务器上的,而不是直接存在github的web服务器上,估计是这里面有些政治敏感的内容,所以被屏蔽掉了。

解决办法

1. 将这个开源库镜像到码云上

https://gitee.com/cedardiao/libcommon

2. 找到资源在码云上的路径

https://gitee.com/cedardiao/libcommon/tree/master/repository/com/serenegiant/common

点开里面的:maven-metadata.xml文件:

https://gitee.com/cedardiao/libcommon/blob/master/repository/com/serenegiant/common/maven-metadata.xml

将鼠标放到“原始数据”位置,右键,复制链接地址:

可以得到下面这个链接:

https://gitee.com/cedardiao/libcommon/raw/master/repository/com/serenegiant/common/maven-metadata.xml

取出前面一部分即可:

https://gitee.com/cedardiao/libcommon/raw/master/repository/

3. 修改build.gradle中的URL链接

maven { url 'https://gitee.com/cedardiao/libcommon/raw/master/repository/'}

再次编译可以通过了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值