鍍金池/ 問答/Java  Scala  Android/ 怎么使用阿里云的Gradle Google鏡像?

怎么使用阿里云的Gradle Google鏡像?

在我的項目中需要用到google()來讀取dependencies,見下文:

buildscript {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

其中g(shù)oogle()和jcenter()是被墻的,而 http://maven.aliyun.com/nexus... 并不包括的google() & jcenter(),如果不用它們就會出現(xiàn):

> root project > :app > Resolve files of classpath

卡住的問題……

阿里提供的鏡像包括了Google和Jcenter:

http://maven.aliyun.com/mvn/view

但是如果我這樣用:

google(){ url 'https://maven.aliyun.com/repository/google' }

會報錯:

Could not find method google() for arguments [build_481dup0nhfy99x57ko80vlobp$_run_closure1$_closure2$_closure5@7388ff6f] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
回答
編輯回答
拼未來

有多少個加多少個就行了,放在google()前面

maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url 'https://maven.aliyun.com/repository/google' }
2017年8月7日 18:26