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'
相关推荐
Asin²+cos²=12 小时前
关于Android Studio Koala Feature Drop | 2024.1.2下载不了插件的解决办法
android·ide·android studio
塔塔开!.3 小时前
Maven的依赖
java·maven
划]破3 小时前
Maven的安装及配置
java·maven
讓丄帝愛伱3 小时前
dependencyManagement保持maven的多模块依赖版本一致
java·maven
-seventy-5 小时前
Android 玩机知识储备
android
CYRUS STUDIO5 小时前
frida脚本,自动化寻址JNI方法
android·运维·自动化·逆向·移动安全·jni·frida
暮志未晚Webgl6 小时前
102. UE5 GAS RPG 实现范围技能奥术伤害
android·java·ue5
Patience to do6 小时前
Android Studio项目(算法计算器)
android·算法·android studio
我又来搬代码了10 小时前
【Android】使用TextView实现按钮开关代替Switch开关
android