HarmonyOS | 鸿蒙 鸿蒙开发Gradle构建问题(代理设置错误)

HarmonyOS | 鸿蒙 鸿蒙开发Gradle构建问题(代理设置错误)

一月 02, 2022
该文章更新于 2022.01.02

今天刚开始学习鸿蒙开发,开发第一步构建项目就除了问题,报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A problem occurred configuring root project 'MyFristHarmonyOSAPP'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.huawei.ohos:hap:3.0.3.4.
Required by:
project :
> Could not resolve com.huawei.ohos:hap:3.0.3.4.
> Could not get resource 'https://repo.huaweicloud.com/repository/maven/com/huawei/ohos/hap/3.0.3.4/hap-3.0.3.4.pom'.
> Could not GET 'https://repo.huaweicloud.com/repository/maven/com/huawei/ohos/hap/3.0.3.4/hap-3.0.3.4.pom'.
> Connect to 127.0.0.1:1080 [/127.0.0.1] failed: Connection refused: connect
> Could not resolve com.huawei.ohos:hap:3.0.3.4.
> Could not get resource 'https://developer.huawei.com/repo/com/huawei/ohos/hap/3.0.3.4/hap-3.0.3.4.pom'.
> Could not GET 'https://developer.huawei.com/repo/com/huawei/ohos/hap/3.0.3.4/hap-3.0.3.4.pom'.
> Connect to 127.0.0.1:1080 [/127.0.0.1] failed: Connection refused: connect
> Could not resolve com.huawei.ohos:decctest:1.2.6.0.
Required by:
project :
> Could not resolve com.huawei.ohos:decctest:1.2.6.0.

官方解决办法如下:

  • Windows:

    1
    `gradle`代理设置错误,可以将`gradle`默认路径:`C:\Users\{你的电脑账号}\.gradle`下配置的`gradle.properties`代理文件删除之后重新同步。

img

  • Mac:

    1
    根目录下的gradle.properties中有关代理的设置都去掉,然后退出编译器,重新打开工程,重新同步。

删除gradle配置文件后退出开发工具,重新打开后刷新gradle,终于成功了

img