5

Android Studio通过gradle同步工程失败

 2 years ago
source link: https://xmanyou.com/android-studio-gradle-sync-fail/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
25 February 2020 / 开发笔记

Android Studio通过gradle同步工程失败

最近遇到一个奇怪的问题,不确定是怎么出现的,但是记录一下解决的过程。

Android Studio 版本:3.4.1

AndroidStudio_version

正常情况下,要想能够使用Android Studio来更新Android的各种插件,我们需要在Android Studio里配置proxy:

AndroidStudio_http_proxy

这个配置很久以来一直都工作很正常,昨天突然就报错了
AndroidStudio_sync_fail

奇怪了,明明给gradle配置了proxy,为什么会失败了呢?

AndroidStudio_gradle_global_proxy

  1. 禁用gradle代理
    AndroidStudio_gradle_global_proxy_disable

然后sync时,不要把Android Studio的proxy设置同步到gradle里,弹窗选择Cancel
AndroidStudio_auto_proxy

然后,就sync就成功了……
AndroidStudio_sync_success

禁用了代理,反而成功了???
对。
为什么?
我不知道……

  1. 使用国内镜像
    这是一个比较安全的做法。
//        google()
//        jcenter()

   maven{ url 'https://maven.aliyun.com/repository/google'}
   maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
   maven{ url 'https://maven.aliyun.com/repository/public'}
   maven{ url 'https://maven.aliyun.com/repository/jcenter'}

我又测试了一下,关闭Androi Studio自己代理,打开Sdk Manager,好像也一切正常……

AndroidStudio_no_proxy

AndroidStudio_sdk_site

先记录下来,后边又新发现再更新。

阿斌

Read more posts by this author.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK