美文网首页
Gradle使用国内源(阿里云源)

Gradle使用国内源(阿里云源)

作者: 简单点的笨演员 | 来源:发表于2021-03-29 14:24 被阅读0次

Gradle在国内经常抽风,一直使用梯子来使用倒是没有出现什么问题,今天梯子被墙了,Gradle就用不了。最近好像查的有点严,估计梯子一时好不了,试试换gradle国内源。没有想到换了国内源比用梯子更快,故特在此记录一下。

关闭Gradle的代理(如果没有设置代理跳过这一步):

打开文件C:\Users\Administrator.gradle\gradle.properties,注释设置代理的行。

## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Jan 23 16:06:06 CST 2021

#systemProp.http.proxyHost=127.0.0.1
#systemProp.http.proxyPort=1081
#systemProp.https.proxyHost=127.0.0.1
#systemProp.https.proxyPort=1081

更换Gradle国内源

打开项目根目录的gradle.properties,注释所有google()和jcenter()的行,添加阿里云的源:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
       // google()
       // jcenter()
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
        maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        

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

allprojects {
    repositories {
      //  google()
      //  jcenter()
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
        maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
    }
}

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

参考:
https://www.jianshu.com/p/319e7a8faa6a

相关文章

  • Gradle使用国内源(阿里云源)

    Gradle在国内经常抽风,一直使用梯子来使用倒是没有出现什么问题,今天梯子被墙了,Gradle就用不了。最近好像...

  • mac brew更换国内源

    mac的brew修改国内源 清华源 阿里云 腾讯源 清华源(本人在用) 阿里云 腾讯源 参考 mac home b...

  • ubuntu基础配置(慢慢更新)

    壹.更换国内源: 安装Ubuntu后,使用国外源速度很慢,修改为国内源会快很多,修改阿里源为Ubuntu 18.0...

  • gradle切换为阿里云镜像

    build.gradle 默认的仓库为 使用起来非常不便。于是将源换成阿里云的源,打开 https://maven...

  • Linux搭建Hyperledger Fabric v1.1.0

    安装依赖 使用国内的阿里源安装docker 当然也可以使用别的源,因为我的是阿里服务器,所以就选国内源了,其它源百...

  • mac的brew修改国内源

    mac的brew修改国内源 清华源阿里云腾讯源清华源(本人在用)

  • Ubuntu 更换国内源

    Ubuntu 更换国内源 阿里云源 yun-idc (这个源可以RSYNC) 更新 模版都一样,只修改域名即可

  • Ubuntu 18.04 国内源

    18.04后,使用国外源太慢了,修改为国内源会快很多。 修改阿里源为Ubuntu 18.04默认的源 备份/etc...

  • python相关指令

    pip国内源加速 可以在使用pip的时候在后面加上-i参数,指定pip源 pip国内的一些镜像 阿里云 https...

  • Ubuntu 18.04修改默认源为国内源

    安装Ubuntu18.04后,使用国外源太慢了,修改为国内源会快很多。 修改阿里源为Ubuntu 18.04默认的...

网友评论

      本文标题:Gradle使用国内源(阿里云源)

      本文链接:https://www.haomeiwen.com/subject/hwcbhltx.html