I am trying to migrate my Android project to use the new Compose compiler and switched from Groovy syntax to Kotlin. Gradle sync now fails with this error:
Error resolving plugin [id: 'com.android.application', version: '8.8.1', apply: false]
The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
I already tried different combinations of using alias
, getId
and apply false
, but none of them helped.
My build.gradle.kts - module:
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.compose.compiler) apply false
}
android {
namespace = "com.kaufmannmarek.dochazsys"
compileSdk = 35
compileOptions {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
kotlinOptions {
jvmTarget = "19"
}
defaultConfig {
applicationId = "com.kaufmannmarek.dochazsys"
minSdkVersion = 23
targetSdkVersion = 35
versionCode = 23
versionName = "2502031045"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
composeCompiler {
enableStrongSkippingMode = true
}
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.legacy.support.v4)
implementation(libs.androidx.core.ktx)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.runner)
androidTestImplementation(libs.androidx.espresso.core)
implementation(libs.okhttp)
implementation(libs.okhttp.urlconnection)
implementation(libs.jasypt)
implementation(libs.kotlin.stdlib)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.ui)
implementation(libs.androidx.runtime)
implementation(libs.kotlin.compose.compiler.plugin.embeddable)
implementation(libs.kotlin.compose.compiler.plugin)
}
My libs.version.toml:
[versions]
appcompat = "1.7.0"
coreKtx = "1.15.0"
espressoCore = "3.6.1"
agp = "8.8.1"
gradle = "8.8.1"
jasypt = "1.9.3"
junit = "4.13.2"
kotlinComposeCompilerPlugin = "2.0.21"
kotlinGradlePlugin = "2.0.21"
kotlinStdlib = "2.0.21"
legacySupportV4 = "1.0.0"
material = "1.12.0"
constraintlayout = "2.2.0"
navigationFragmentKtx = "2.8.7"
okhttp = "2.7.5"
runner = "1.6.2"
runtime = "1.7.8"
ui = "1.7.8"
kotlin = "2.0.21"
[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCore" }
androidx-legacy-support-v4 = { module = "androidx.legacy:legacy-support-v4", version.ref = "legacySupportV4" }
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
androidx-runner = { module = "androidx.test:runner", version.ref = "runner" }
androidx-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "runtime" }
androidx-ui = { module = "androidx.compose.ui:ui", version.ref = "ui" }
gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
jasypt = { module = "org.jasypt:jasypt", version.ref = "jasypt" }
junit = { module = "junit:junit", version.ref = "junit" }
kotlin-compose-compiler-plugin = { module = "org.jetbrains.kotlin:kotlin-compose-compiler-plugin", version.ref = "kotlinComposeCompilerPlugin" }
kotlin-compose-compiler-plugin-embeddable = { module = "org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinGradlePlugin" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlinStdlib" }
material = { module = "com.google.android.material:material", version.ref = "material" }
okhttp = { module = "com.squareup.okhttp:okhttp", version.ref = "okhttp" }
okhttp-urlconnection = { module = "com.squareup.okhttp:okhttp-urlconnection", version.ref = "okhttp" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
My build.gradle.kts - project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath(libs.gradle)
classpath(libs.kotlin.gradle.plugin)
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
tasks.register("clean", Delete::class) {
layout.buildDirectory.set(layout.projectDirectory.dir("out"))
}
thanks everyone for feedback.
So the solution was quite simple and in case the only thing that was basically needed was to put code below to project build.gradle.kts
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.compose.compiler) apply false
}
while my module build.gradle.kts looks like this:
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.compose.compiler)
}
Once more thank you!