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, butmaven { url 'https://maven.google.com' }
works whilegoogle()
not.
In generalmaven { url 'https://maven.google.com' }
is somehow a better choice thangoogle()
.
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()
}
...
}