当前位置:   article > 正文

Andorid Stdio 在 加载gradle时特别慢 的解决办法_android studio 下载gradle很慢

android studio 下载gradle很慢

Andorid Stdio 在 加载gradle时特别慢 的解决办法

问题描述

在进行RK3566 Android 的定制中 遇到一个问题,在使用android stdio开发客制版浏览器的时候,在加载gradle时特别慢,半个多小时还没加载完,最终在网上找到了解决方法,记录一下。

在这里插入图片描述

解决方案如下

使用阿里提供的仓库进行下载依赖包。阿里仓库网站,包含jcenter、maven、Google仓库,网站是 https://developer.aliyun.com/mvn/guide

计算机的c盘的用户目录下找到.gradle,在文件夹内新建文件init.gradle 文件。目录结构如下

在init.gradle加入如下代码,并保存

  • gradle.projectsLoaded {
        rootProject.allprojects {
            buildscript {
                repositories {
                    def JCENTER_URL = 'https://maven.aliyun.com/repository/public'
                    def GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
                    def NEXUS_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
                    all { ArtifactRepository repo ->
                        if (repo instanceof MavenArtifactRepository) {
                            def url = repo.url.toString()
                            if (url.startsWith('https://jcenter.bintray.com/')) {
                                project.logger.lifecycle "Repository ${repo.url} replaced by $JCENTER_URL."
                                println("buildscript ${repo.url} replaced by $JCENTER_URL.")
                                remove repo
                            }
                            else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
                                project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL."
                                println("buildscript ${repo.url} replaced by $GOOGLE_URL.")
                                remove repo
                            }
                            else if (url.startsWith('https://repo1.maven.org/maven2')) {
                                project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                                println("buildscript ${repo.url} replaced by $REPOSITORY_URL.")
                                remove repo
                            }
                        }
                    }
                    jcenter {
                        url JCENTER_URL
                        allowInsecureProtocol = true
                    }
                    google {
                        url GOOGLE_URL
                        allowInsecureProtocol = true
                    }
                    maven {
                        url NEXUS_URL
                        allowInsecureProtocol = true
                    }
                }
            }
            repositories {
                def JCENTER_URL = 'https://maven.aliyun.com/repository/public'
                def GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
                def NEXUS_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
                all { ArtifactRepository repo ->
                    if (repo instanceof MavenArtifactRepository) {
                        def url = repo.url.toString()
                        if (url.startsWith('https://jcenter.bintray.com/')) {
                            project.logger.lifecycle "Repository ${repo.url} replaced by $JCENTER_URL."
                            println("buildscript ${repo.url} replaced by $JCENTER_URL.")
                            remove repo
                        }
                        else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
                            project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL."
                            println("buildscript ${repo.url} replaced by $GOOGLE_URL.")
                            remove repo
                        }
                        else if (url.startsWith('https://repo1.maven.org/maven2')) {
                            project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                            println("buildscript ${repo.url} replaced by $REPOSITORY_URL.")
                            remove repo
                        }
                    }
                }
                jcenter {
                    url JCENTER_URL
                    allowInsecureProtocol = true
                }
                google {
                    url GOOGLE_URL
                    allowInsecureProtocol = true
                }
                maven {
                    url NEXUS_URL
                    allowInsecureProtocol = true
                }
            }
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81

然后再把android stdio 重启后发现之前慢吞吞的下载 已经像是吃了菠菜的大力水手一样给力了。

最终结果

(https://blog.csdn.net/u014687242/article/details/121132481)

最后将android stdio 重启后发现之前慢吞吞的加载,已经像是吃了菠菜的大力水手一样给力了。

学艺不精,有什么问题希望各位大佬指正。

参考链接

https://blog.csdn.net/u014687242/article/details/121132481

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/287833
推荐阅读
相关标签
  

闽ICP备14008679号