compose-multiplatform: Compile error in kmp Android target after upgrading to 1.5.0-rc01

When adding below line of code used for Composable Preview in Android sourceset, the build fails.

buildFeatures {   
    compose = true    
}

Compilation fails with bellow message:

> Task :shared:compileDebugKotlinAndroid FAILED
e: java.lang.ClassCastException: Cannot cast androidx.compose.compiler.plugins.kotlin.ComposePluginRegistrar to org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Add bellow line in gradle android dsl
buildFeatures {   
    compose = true    
}
  1. Try to build the Android App.

Expected behavior App should build ok

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 1
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

This issue is solved by upgrading to androidx.compose.compiler 1.5.2

I think we should have a compatibility table on the repo readme in the future, so we can follow along when updating.

I’ve updated to 1.5.0-rc04 and it also fails with the same error:

java.lang.ClassCastException: Cannot cast androidx.compose.compiler.plugins.kotlin.ComposePluginRegistrar to org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar

beta02 the latest working version for me

I updated to 1.5.0-rc01 and it also fails with

java.lang.ClassCastException: Cannot cast androidx.compose.compiler.plugins.kotlin.ComposePluginRegistrar to org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar

beta01 and beta02 working fine

Hi @mazunin-v-jb Sorry for misleading on the desktop target comment, it seems to be a different thing. The error seems to be associated with using bellow code in the Composable that is previewed.

Window(
      state = windowState,
      onCloseRequest = { onExitClick() }
  ) {
      MenuBar {
           ...
     }
}

Once I removed that part from the Composable the Preview works ok. I will ask in kotlinlang slack and if I don’t find an answer I open a new issue. But I don’t think rendering desktop window menus is supported by the desktop previewer. In any case is a separate problem not associated with this issue. Thanks

@mazunin-v-jb Compiles and runs good. The Preview is the one not working. It shows an error, not sure if is better to open another issue for that.

Hi @dima-avdeev-jb Here is a reproducible using JB template: https://github.com/pablichjenkov/cmp_issue_3531_repro 1.4.3 works fine, the last commit message list the steps of things that I upgrade to be able to run 1.5.0-rc01. Basically it forces to upgrade the Android targetSDK to 34 for some emoji stuff.

I tried to update to 1.5.0-rc01 and it also fails with same log error for me.

Until beta02 everything seems to work fine (even though beta02 has a dependency that makes me use Android API 34, but build result in success after changing android api)

Build fails in rc01: https://github.com/fernandozanutto/water-reminder/tree/build-fails-compose-1.5.0-rc01

Build success in beta01: https://github.com/fernandozanutto/water-reminder/tree/build-success-compose-1.5.0-beta01