score:7

Accepted answer

i finally fixed it by declaring an explicit dependency on androidx.activity:activity-compose (similar to this answer) in both my app module as well as my compose module, which the app module depends on. before, i declared the activity compose dependency only in my compose module, not my app module.

this is what my setup looks like now:

// build.gradle (:app)
android {
    ...

    buildfeatures {
        compose true
    }

    composeoptions {
        kotlincompilerextensionversion versions.compose
    }

    compileoptions {
        sourcecompatibility javaversion.version_1_8
        targetcompatibility javaversion.version_1_8
    }

    kotlinoptions {
        jvmtarget = '1.8'
    }
}
dependencies {
    implementation project(':core')
    implementation project(':common-ui-compose')
    ...

    implementation libs.androidx.activity.activitycompose
// build.gradle (:common-ui-compose)
android {
    ...

    buildfeatures {
        compose true
    }

    composeoptions {
        kotlincompilerextensionversion versions.compose
    }

    compileoptions {
        sourcecompatibility javaversion.version_1_8
        targetcompatibility javaversion.version_1_8
    }

    kotlinoptions {
        jvmtarget = '1.8'
    }
}

dependencies {
    implementation project(':core')
    ...
    implementation libs.androidx.activity.activitycompose

score:0

in a multi-module project with kts:

class mylibraryplugin : plugin<project> {
    override fun apply(project: project) {
        with(project) {
            plugins.all {
                dependencies {
                    implementation("androidx.compose.runtime:runtime:1.0.1")//specify the version
                }
            }
        }
    }
}

score:9

you need to add compose runtime dependency.

dependencies {
    def compose_version = "1.0.0-beta07"
    implementation("androidx.compose.runtime:runtime:$compose_version")
}

Related Query

More Query from same tag