Trying to follow Jeroen Mols modularization sample, he specifies a nice technique to allow all modules to share version numbers. In the top level project build.gradle, add this:
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
android {
compileSdkVersion build_versions.target_sdk
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
}
}
Now any module level build.gradle files do not need to specify these fields. However I get:
GradleException: Android tasks have already been created.
I am not specifying android.applicationVariants, android.libraryVariants or android.testVariants like the description to this error mentions so what could I be doing wrong here? I have even tried removing the android block from every module completely and the error persists.