I have a complex multi-module Kotlin multi-platform project.
It has a
buildSrc
module loading several common Gradle plugins, used by precompiled script plugins:
// buildSrc/build.gradle.kts
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
...
}
The project had no Android support, but now I'd like add the
Android plugin as well to one of the sub-modules.
It seems that I have to add it to
buildSrc
as well, otherwise I get the error (which seems to be a Gradle classloading conflict):
Unable to load class 'com.android.build.gradle.api.BaseVariant'.
So I added it to
buildSrc
as well:
// buildSrc/build.gradle.kts
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
...
implementation("com.android.tools.build:gradle:8.1.1")
}
Gradle sync now works in Idea but when I try to compile the project, errors like the following appear:
Cannot locate tasks that match ':kotlinw:kotlinw-remoting-client-ktor:compileJava' as task 'compileJava' not found in project ':kotlinw:kotlinw-remoting-client-ktor'.
Which I don't understand because the given project is a Kotlin-only project, it has no Java sources, and the
Android plugin is not applied to it...
Do you have any idea what is happening? Thanks.