I am trying to create a precompiled script plugin in buildSrc, and the plugin just contains the necessary stuffs required for an android library module
val libs = the<LibrariesForLibs>()
plugins {
id("com.android.library")
}
android {
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
}
}
In the buildSrc build.gradle, added the necessary dependencies for the android plugin
dependencies {
implementation("com.android.tools.build:gradle:8.0.2")
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
My root build.gradle has the below code
plugins {
//trick: for the same plugin versions in all sub-modules
id("com.android.application").version("8.0.2").apply(false)
id("com.android.library").version("8.0.2").apply(false)
kotlin("android").version("1.8.21").apply(false)
kotlin("multiplatform").version("1.8.21").apply(false)
}
Since the library plugin is applied at root level, when i add the android.tools.build dependency in buildSrc build.gradle, its failing as its unable to verify the versions used in the plugin. (this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked)
What’s the right way to go abt this problem. Can someone throw some light on this issue. Removing the plugins from root build.gradle fixes the compilation issue, but then it creates issues during runtime. Appreciate your help here