简体   繁体   English

google() 和 maven { url 'https://maven.google.com' } 之间的区别

[英]Difference between google() and maven { url 'https://maven.google.com' }

Is there any difference between google() and maven { url ' https://maven.google.com ' } in build.gradle file and if there is any, what is it? build.gradle 文件中的 google() 和 maven { url ' https://maven.google.com ' } 之间有什么区别吗?如果有的话,那是什么?

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        // OR
        google()
    }
}

The google() repository is a shortcut to Google's maven repository. google()存储库是Google maven资源库的快捷方式。 It was introduced in Gradle 4.x+. 它是在Gradle 4.x +中引入的。 The actual repository URL used is `" https://dl.google.com/dl/android/maven2/ " as specified here. 使用的实际存储库URL是“ https://dl.google.com/dl/android/maven2/ ”,如此处所指定 https://maven.google.com actually points to the same repository. https://maven.google.com实际上指向同一个存储库。

However, if you are planning to use the google() shortcut, you need Gradle 4.x+, Android Studio 3.x+ and Gradle plugin for Android 3.x+. 但是,如果您打算使用google()快捷方式,则需要Gradle 4.x +,Android Studio 3.x +和Android 3.x +的Gradle插件。

Small correction to the answer above. 小修正上面的答案。 If you try to go to https://dl.google.com/dl/android/maven2/ it gives you a 404. The correct url to google maven repository is: 如果您尝试访问https://dl.google.com/dl/android/maven2/ ,则会显示404.Google maven存储库的正确网址为:

https://dl.google.com/dl/android/maven2/index.html or just https://maven.google.com https://dl.google.com/dl/android/maven2/index.html或只是https://maven.google.com

Here you can check all the supported libraries and the latest versions. 在这里,您可以检查所有支持的库和最新版本。

When using gradle, you can mention multiple repositories which the build tool (gradle) uses to resolve dependencies mentioned in your project.使用 gradle 时,您可以提及构建工具 (gradle) 用于解决项目中提及的依赖项的多个存储库。

repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
    google()
}

In the above scenario, you're mentioning 3 repositories which gradle can use to resolve dependencies—all of which are Maven repositories.在上面的场景中,您提到了 gradle 可以用来解决依赖关系的 3 个存储库——它们都是 Maven 存储库。

1. jcenter() 1.j中心()

  • Means the JCenter Maven repository.表示JCenter Maven存储库。
  • This is a shortcut available in later versions of gradle这是gradle以后版本才有的快捷方式

2. { url 'https://maven.google.com' } 2. { url 'https://maven.google.com' }

  • This means you are referring a Maven repo hosted at the URL which can be used by gradle to resolve the dependencies.这意味着您指的是托管在 URL 的 Maven 存储库,gradle 可以使用它来解决依赖关系。
  • If you want, you can actually enter the URL for JCenter and this would be the same as mentioning jcenter() in the gradle file.如果需要,您实际上可以为 JCenter 输入 URL,这与在 gradle 文件中提及jcenter()相同。

3. google() 3.谷歌()

  • This means the Google Maven repository这意味着 Google Maven 存储库
  • Similar to the notation maven() , this can be used in later versions of gradle only类似于maven()符号,这只能在 gradle 的更高版本中使用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 maven { url 'https://maven.google.com' } 不断从我的 gradle 中消失 - maven { url 'https://maven.google.com' } keep disapearing from my gradle Maven com.google无法解析为输入 - Maven com.google cannot be resolved to type 无法获取“https://google.bintray.com/.../maven-metadata.xml”。 从服务器收到状态代码 403:禁止访问 - Could not GET 'https://google.bintray.com/.../maven-metadata.xml'. Received status code 403 from server: Forbidden Maven依赖关系以使用com.google.common.graph.ImmutableDirectedGraph - Maven dependency to use com.google.common.graph.ImmutableDirectedGraph 无法获取“https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.0.2/gradle-7.0.2.pom” - Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.0.2/gradle-7.0.2.pom' Maven | java.lang.NoClassDefFoundError:com / google / common / base / Strings - Maven | java.lang.NoClassDefFoundError: com/google/common/base/Strings Google 电子表格的 Maven 依赖项 - Maven dependency for Google Spreadsheet Java google checkstyle Maven - Java google checkstyle Maven Maven GAE无法执行目标com.google.appengine:appengine-maven-plugin:1.9.12:devserver [...] NoSuchElementException - Maven GAE Failed to execute goal com.google.appengine:appengine-maven-plugin:1.9.12:devserver […] NoSuchElementException 无法获取“https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom” - Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM