Please explain why the first code gives me syncing errors while the second doesn't.
allprojects {
repositories {
jcenter()
google()
}
}
Failed to resolve: play-services-base Open File
Failed to resolve: play-services-tasks Open File
Changing the repository order syncs just fine:
allprojects {
repositories {
google()
jcenter()
}
}
Can someone give me a reason or educated guess why this occurs?
The order inside the dependencies { } block is preserved. You are kind of right. Dependency ordering is preserved, but for example all compile dependencies will be before testCompile dependencies no matter of how you order them.
During this phase, Gradle identifies the tasks that need to be executed based on the DAG of task objects created in the previous phase, and executes them according to their dependency order. All the build work and activities are actually done in this phase. For example: compiling source code and generating .
Releases of a module hosted on a repository can provide metadata to declare those transitive dependencies. By default, Gradle resolves transitive dependencies automatically. The version selection for transitive dependencies can be influenced by declaring dependency constraints.
This doc might be of use for you:
https://docs.gradle.org/current/userguide/declaring_repositories.html
Right down the bottom it mentions:
Note: The order of declaration determines how Gradle will check for dependencies at runtime. If Gradle finds a module descriptor in a particular repository, it will attempt to download all of the artifacts for that module from the same repository. You can learn more about the inner workings of Gradle’s resolution mechanism.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With