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

Android studio shows Could not find runtime.aar (android.arch.lifecycle:runtime:1.0.0)., as suggested, add maven { url 'https://maven.google.com' } to file build.gradle(project level):

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

The weird thing is google() already exists in the gradle file.
As the document:

MavenArtifactRepository google()
Adds a repository which looks in Google's Maven repository for dependencies.
The URL used to access this repository is "https://dl.google.com/dl/android/maven2/".

Examples:

 repositories {
     google()
 }
 
Returns:
the added resolver
Since:
4.0

Seems google() is the same as maven { url 'https://maven.google.com' } as long as:

  • Gradle 4.0 and later
  • Android Studio 3.0 and later
  • Gradle plugin for android 3.0 and later
    Anyway, it's weird since I'm sure all the three options are satisfied, but maven { url 'https://maven.google.com' } works while google() not.
    In general maven { url 'https://maven.google.com' } is somehow a better choice than google().

Found something:

It's actually not something to do with maven { url 'https://maven.google.com' } or google(), but something else.
These two situations will fail:

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

Meanwhile these two situations will pass:

allprojects {
    repositories {
        google()
        jcenter()
    }
...
}
allprojects {
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
...
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    wgl0419阅读 6,360评论 1 9
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,569评论 2 45
  • 1.底线 一搞模特行业的专业人士。正是个美男子,他还在照镜子。 忽地来了两个人,贴小广告的。误打误撞,这两人,都称...
    玉闲君阅读 200评论 0 2
  • 在生活中,处处可见运用影响力来影响他人达到目的的现象,只不过在系统的读这本书前,你不会知道自己被套路了,也...
    misself阅读 307评论 0 0
  • 时间:2018年1月23日 学号:SWSZ807 姓名:王黎娜 课程总结: 今天学习的是天瑜老师的《巧用思维导图做...
    璋妈阅读 2,925评论 2 3