Gradle cannot find Android Compose Compiler
Had the same issue and resolved after updating the gradle version to
classpath "com.android.tools.build:gradle:4.2.0-alpha14"
and instead of declaring compiler version kotlinCompilerExtensionVersion
in the composeoptions, decalred as a dependency
implementation "androidx.ui:ui-tooling:$compose_version"implementation "androidx.compose.runtime:runtime:$compose_version"implementation "androidx.compose.compiler:compiler:$compose_version"
I had to upgrade my Gradle version:
buildscript { dependencies { classpath "com.android.tools.build:gradle:7.0.0-alpha02"
I was having a very similar problem, but when running an Android project in IntelliJ IDEA, not Android Studio.
I seems that upgrading the com.android.tools.build:gradle
dependency indeed fixed the original problem ("Gradle cannot find Android Compose Compiler"), but then I started having other problems, so had to find another way.
I used IDEA's new project wizard, then selected Kotlin, then "Multiplatform" (under Jetpack Compose for Desktop group). This created a new project with an Android module, a Desktop module and a Common module. From this template, I basically copied how the Android and Common modules are setup into my original Android project.
The main difference is that JetBrains seems to provide a (yet another) Gradle plugin (org.jetbrains.compose
) that sets up Compose for us (because of some changes to also support desktop, I guess), and with this plugin, everything seems to work and the "Gradle cannot find Android Compose Compiler" is gone.
This is the plugin used in the new project template:
id("org.jetbrains.compose") version "0.3.0"
This is how Compose dependencies are added:
api("androidx.core:core-ktx:1.3.2")api(compose.runtime)api(compose.foundation)api(compose.material)api(compose.ui)implementation("androidx.activity:activity-compose:1.3.0-alpha03")
Keep in mind that I'm not necessarily using Desktop here, at least not for now, but that was the only way I could make an Android app work with the latest (2021+) releases of Compose with just IDEA (not Android Studio) installation.