Android gradle和maven国内镜像地址

在Android 开发中经常会出现gradle或者maven依赖下载过慢或者失败的情况,如果出现这种情况的话,那就需要使用国内镜像地址,本文章仅作记录,方便后续查取。

gradle国内镜像地址

这里提供的是腾讯的国内gradle镜像地址。

Groovy 复制代码
https://mirrors.cloud.tencent.com/gradle/

配置方式,在项目根目录下gradle/wrapper/gradle-wrapper.properties中如下配置:

Groovy 复制代码
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

maven国内镜像地址

这里提供的是阿里国内的maven镜像地址。

Groovy 复制代码
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
maven { setUrl("https://maven.aliyun.com/repository/public") }
maven { setUrl("https://jitpack.io") }

老版本Android Studio在项目根目录下的build.gradle中配置,配置方式如下:

Groovy 复制代码
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        maven { setUrl("https://maven.aliyun.com/repository/central") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        maven { setUrl("https://maven.aliyun.com/repository/google") }
        maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
        maven { setUrl("https://maven.aliyun.com/repository/public") }
        maven { setUrl("https://jitpack.io") }
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { setUrl("https://maven.aliyun.com/repository/central") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        maven { setUrl("https://maven.aliyun.com/repository/google") }
        maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
        maven { setUrl("https://maven.aliyun.com/repository/public") }
        maven { setUrl("https://jitpack.io") }
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

新版本Android Studio在项目根目录下的settings.gradle中配置,配置方式如下:

Groovy 复制代码
pluginManagement {
    repositories {
        maven { setUrl("https://maven.aliyun.com/repository/central") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        maven { setUrl("https://maven.aliyun.com/repository/google") }
        maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
        maven { setUrl("https://maven.aliyun.com/repository/public") }
        maven { setUrl("https://jitpack.io") }
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven { setUrl("https://maven.aliyun.com/repository/central") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        maven { setUrl("https://maven.aliyun.com/repository/google") }
        maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
        maven { setUrl("https://maven.aliyun.com/repository/public") }
        maven { setUrl("https://jitpack.io") }
        google()
        mavenCentral()
    }
}
rootProject.name = "xxx"
include ':app'
相关推荐
XiaoLeisj8 分钟前
Android 短视频项目实战:从用户中心页与沉浸式登录,到验证码鉴权、用户信息持久化和 EventBus 登录态同步
android·webview·eventbus·countdowntimer·token 加密·键值对存储 sp·封装toast/加载 ui
JJay.1 小时前
Android BLE 扫描连接与收发消息实战
android
fly spider2 小时前
MySQL索引篇
android·数据库·mysql
xinhuanjieyi2 小时前
php setplayersjson实现类型转换和文件锁定机制应对高并发
android·开发语言·php
533_3 小时前
[vxe-table] 表头:点击出现输入框
android·java·javascript
邹阿涛涛涛涛涛涛3 小时前
Jetpack Compose Modifier 深度解析:从链式调用到 Modifier.Node
android
jinanwuhuaguo3 小时前
OpenClaw 2026年4月升级大系深度解读剖析:从“架构重塑”到“信任内建”的范式跃迁
android·开发语言·人工智能·架构·kotlin·openclaw
huhy~4 小时前
基于Ubuntu 24.04 LTS 搭建OpenStack F 版
android·ubuntu·openstack
2401_885885044 小时前
视频短信接口接入麻不麻烦?API调用说明
android·音视频
lI-_-Il5 小时前
喜马拉雅 v9.4.56.3:移动端全站音频资源畅听版
android·音视频