首页 > 其他分享 >【Android Studio】通过编辑setting.gradle文件,添加阿里仓库

【Android Studio】通过编辑setting.gradle文件,添加阿里仓库

时间:2023-03-06 19:00:53浏览次数:56  
标签:https repository url gradle maven setting Studio aliyun com

本人对Android Studio的了解非常初级,这篇blog主要是自用备忘性质。

因为众所周知的原因,国外仓库访问很不方便,影响项目构建。所以需要添加国内仓库,而阿里云仓库属于比较知名的。

阿里云仓库服务

自Android Studio Bumblebee(2021.1.1) 开始,仓库地址的存放位置,从项目级别的build.gradle改为了setting.gradle。

下面是我的一个测试项目中setting.gradle文件的代码,IDE版本:Android Studio Electric Eel | 2022.1.1 Patch 1

 

pluginManagement {
    repositories {
      //下面3行是自动生成的,因为影响构建速度就被我注释掉了,实际是否需要请自行斟酌。
        /*google()
        mavenCentral()
        gradlePluginPortal()*/
        // 以下四行添加阿里云的仓库地址,方便国内开发者下载相关插件
        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/central'}
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
     //下面2行是自动生成的,因为影响构建速度就被我注释掉了,实际是否需要请自行斟酌。
        /*google()
        mavenCentral()*/
        // 以下四行添加阿里云的仓库地址,方便国内开发者下载相关插件
        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/central'}
    }
}
rootProject.name = "My Application"
include ':test'

 

标签:https,repository,url,gradle,maven,setting,Studio,aliyun,com
From: https://www.cnblogs.com/infocodez/p/17184958.html

相关文章