Skip to content

Issue with Compose BOM 2025.10.00 and Kotlin 2.x Compiler Integration #1388

@amary21

Description

@amary21

Description

I'm encountering a compiler error when using the latest Compose BOM (androidx.compose:compose-bom:2025.10.00) with Kotlin 2.x in Bazel.

With Kotlin 2.0+, the Compose Compiler is now integrated into the Kotlin compiler itself (matching the Kotlin version), rather than being a separate dependency. However, I'm getting the following error:

Argument type mismatch: actual type is 'Function0<Unit>', but '@Composable() ComposableFunction0<Unit>' was expected.

Environment

  • Bazel version: 8.4.2
  • rules_kotlin version: 2.1.9
  • Compose BOM version: 2025.10.00

Configuration

MODULE.bazel

module(
    name = "mymovie",
    version = "1.0.0",
    compatibility_level = 1,
)

bazel_dep(name = "rules_java", version = "8.14.0")
bazel_dep(name = "rules_android", version = "0.6.6")
bazel_dep(name = "rules_kotlin", version = "2.1.9")
bazel_dep(name = "rules_jvm_external", version = "6.8")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "bazel_skylib", version = "1.7.1")

register_toolchains("@rules_java//java:all")

remote_android_extensions = use_extension(
    "@rules_android//bzlmod_extensions:android_extensions.bzl",
    "remote_android_tools_extensions")
use_repo(remote_android_extensions, "android_tools")
android_sdk_repository_extension = use_extension(
    "@rules_android//rules/android_sdk_repository:rule.bzl",
    "android_sdk_repository_extension")
android_sdk_repository_extension.configure(
    path = "/Users/macbookpro/Library/Android/sdk",
    api_level = 36,
    build_tools_version = "36.0.0",
)
use_repo(android_sdk_repository_extension, "androidsdk")
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.artifact(
    artifact = "activity",
    group = "androidx.activity",
    version = "1.11.0",
)
maven.artifact(
    artifact = "collection-jvm",
    group = "androidx.collection",
    version = "1.5.0",
)
maven.artifact(
    artifact = "lifecycle-common",
    group = "androidx.lifecycle",
    version = "2.8.7",
)
maven.artifact(
    artifact = "lifecycle-runtime",
    group = "androidx.lifecycle",
    version = "2.8.7",
)
maven.artifact(
    artifact = "lifecycle-viewmodel",
    group = "androidx.lifecycle",
    version = "2.8.7",
)
maven.artifact(
    artifact = "savedstate",
    group = "androidx.savedstate",
    version = "1.3.3",
)
maven.install(
    known_contributing_modules = ["bazel_worker_java", "mymovie"],
    boms = [
        "androidx.compose:compose-bom:2025.10.00",
    ],
    artifacts = [
        "org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable:2.1.20",
        "androidx.core:core-ktx:1.17.0",
        "junit:junit:4.13.2",
        "androidx.test.ext:junit:1.3.0",
        "androidx.test.espresso:espresso-core:3.7.0",
        "androidx.lifecycle:lifecycle-runtime-ktx:2.8.7",
        "androidx.lifecycle:lifecycle-viewmodel:2.8.7",
        "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7",
        "androidx.lifecycle:lifecycle-common:2.8.7",
        "androidx.lifecycle:lifecycle-runtime:2.8.7",
        "androidx.activity:activity-compose:1.11.0",
        "androidx.compose.ui:ui",
        "androidx.compose.ui:ui-graphics",
        "androidx.compose.ui:ui-tooling",
        "androidx.compose.ui:ui-tooling-preview",
        "androidx.compose.ui:ui-test-manifest",
        "androidx.compose.ui:ui-test-junit4",
        "androidx.compose.material3:material3",
        "androidx.compose.material:material-icons-core",
    ],
    repositories = [
        "https://maven.google.com",
        "https://repo1.maven.org/maven2",
        "https://repo.maven.apache.org/maven2",
    ],
    version_conflict_policy = "pinned",
    lock_file = "//:maven_install.json",
)

use_repo(maven, "maven")

BUILD.bazel

load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
load("@rules_kotlin//kotlin:core.bzl", "define_kt_toolchain" ,"kt_compiler_plugin")
load("@rules_jvm_external//:defs.bzl", "artifact")

default_java_toolchain(
    name = "java_toolchain",
    visibility = ["//visibility:public"],
)

define_kt_toolchain(
    name = "kotlin_toolchain",
    jvm_target = "1.8",
)

kt_compiler_plugin(
    name = "jetpack_compose_compiler_plugin",
    id = "androidx.compose.compiler.plugins.kotlin",
    target_embedded_compiler = True,
    visibility = ["//visibility:public"],
    options = {
        "suppressKotlinVersionCompatibilityCheck": "2.0.21",
        "sourceInformation": "true",
    },
    deps = [
        artifact("org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable")
    ],
)

platform(
    name = "arm64-v8a",
    constraint_values = [
        "@platforms//cpu:arm64",
        "@platforms//os:android",
    ],
)

platform(
    name = "x86_64",
    constraint_values = [
        "@platforms//cpu:x86_64",
        "@platforms//os:android",
    ],
)

exports_files(["maven_install.json"])

BUILD.bazel (app)

load("@rules_android//android:rules.bzl", "android_binary")
load("@rules_jvm_external//:defs.bzl", "artifact")
load("@rules_kotlin//kotlin:android.bzl", "kt_android_library")

kt_android_library(
    name = "lib",
    srcs = glob(["src/main/java/**/*.kt"]),
    custom_package = "com.amary.my.movie",
    manifest = "src/main/AndroidManifest.xml",
    plugins = ["//:jetpack_compose_compiler_plugin"],
    visibility = ["//visibility:public"],
    resource_files = glob(["src/main/res/**"]),
    deps = [
        artifact("androidx.core:core-ktx"),
        artifact("androidx.lifecycle:lifecycle-runtime-ktx"),
        artifact("androidx.activity:activity-compose"),
        artifact("androidx.compose.runtime:runtime"),
        artifact("androidx.compose.ui:ui"),
        artifact("androidx.compose.ui:ui-graphics"),
        artifact("androidx.compose.ui:ui-tooling"),
        artifact("androidx.compose.ui:ui-tooling-preview"),
        artifact("androidx.compose.material3:material3"),
    ],
)

android_binary(
    name = "app",
    custom_package = "com.amary.my.movie",
    manifest = "src/main/AndroidManifest.xml",
    manifest_values = {
        "applicationId": "com.amary.my.movie",
        "versionCode": "1",
        "versionName": "1.0.0",
        "minSdkVersion": "24",
        "targetSdkVersion": "36",
    },
    deps = [":lib"],
    multidex = "native",
    nocompress_extensions = [".so"],
)

Expected Behavior

The Compose compiler should properly recognize @Composable functions when using the built-in Kotlin 2.x Compose compiler plugin.

Actual Behavior

Getting type mismatch errors for Composable lambda functions, suggesting the Compose compiler plugin may not be properly configured or recognized by rules_kotlin.

Questions

  1. Does rules_kotlin currently support the integrated Compose compiler in Kotlin 2.x?
  2. Is there specific configuration needed to enable the Compose compiler plugin for Kotlin 2.0+?
  3. Are there any known issues with Compose BOM 2025.10.00 and the current version of rules_kotlin?

Additional Context

This error typically occurs when the Compose compiler plugin is not active, causing regular lambda types to not be transformed into Composable function types.

Any guidance on proper configuration would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions