Where do we declare Android dependencies versions in a project?
Should the versions be defined in the project level ex{ } block
or the module level dependencies { } block?
Where do we declare Android dependencies versions in a project?
Should the versions be defined in the project level ex{ } block
or the module level dependencies { } block?
Where do we declare Android dependencies versions in a project?
In brief,
app module etc.) use project's build.gradle,app module only) use app's build.gradleWhen following the rule for a multi-module project, a library's version change is done only in one place and effects all the dependent modules.
Consider the following example with the Kotlin library version.
In project's build.gradle:
ext {
kotlin_version = '1.4.21'
...
kotlin_stdlib = "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
In a module's (e.g. app's) build.gradle:
dependencies {
implementation kotlin_stdlib
...
}
build.gradle - project module with at the bottom
ext.dependenciesVersion = [:]
dependenciesVersion.libraryName = "x.x.x"
build.gradle - app module
implementation "librarySource.$dependencyVersion.libraryName"