Nikolai
07/15/2019, 4:34 PMbuildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
repositories {
google()
jcenter()
}
Why we need repositories here? According to docs it configure repositories for current project. But this is the root file. And it have repositories inside buildscript. This repositories didn't count for subprojects (whats why child build.script have it's own repositories closure). If I remove it - nothing changes, app still build and run (at least on Android). In Android studio this closure looks like :
allprojects {
repositories {
google()
jcenter()
}
}
Which is quite understandable. Maybe I am missing something and this repository closure have some purpose?Casey Brooks
07/15/2019, 4:41 PMrepositories
block in the root project is unnecessary, since the root project isn’t doing anything for itself other than setting up the buildscript.
If you put the repositories
block inside the allprojects
as in your second snippet, then it will be applied to all projects in your build, and you do not need to declare the repositories
in each project’s build.gradle
file.Nikolai
07/15/2019, 4:50 PM