https://kotlinlang.org logo
#decompose
Title
# decompose
a

Adam Brown

12/29/2022, 8:51 PM
Ok i've got a mix of gradle version/multiplatform version/intelliJ version that is actually working, no one touch anything 😂 except after updating various things, my Android Module now thinks it doesn't have a compose runtime:
IncompatibleComposeRuntimeVersionException: The Compose Compiler requires the Compose Runtime to be on the class path, but none could be found. The compose compiler plugin you are using (version 1.3.2) expects a minimum runtime version of 1.0.0.
Anyone run into this before?
l

Landry Norris

12/29/2022, 8:53 PM
Are you using Jetpack Compose or compose-jb? If using compose-jb, make sure to have
compose.runtime
in commonMain.
a

Adam Brown

12/29/2022, 8:54 PM
ya I've got
Copy code
implementation(compose.runtime)
In my common module, also added it to my Android module, it doesnt care
and my desktop target works just fine
the only difference I can think of is in my desktop i've got the platform dependency:
Copy code
implementation(compose.desktop.currentOs)
But theres nothing like that for Android
l

Landry Norris

12/29/2022, 8:57 PM
The same setup (compose-jb + decompose) works for me with
Copy code
implementation(compose.runtime)
                implementation(compose.foundation)
                implementation(compose.material)
                implementation(compose.ui)
                implementation(compose.materialIconsExtended)
in commonMain
a

Adam Brown

12/29/2022, 8:57 PM
what does your Android module look like then?
or don't you have a separate one?
l

Landry Norris

12/29/2022, 8:58 PM
It looks like I kept the same thing in androidMain, but that shouldn’t affect anything. Should be good to remove it from androidMain.
a

Adam Brown

12/29/2022, 8:59 PM
my setup is slight different, I have 3 modules: Android -> ComposeUI -> Common
but shouldnt really matter
l

Landry Norris

12/29/2022, 8:59 PM
I do the same often, setting up a composeMain, commonMain, and {android,ios}Main.
Makes it easier to add/remove iOS support.
a

Adam Brown

12/29/2022, 9:00 PM
ya
l

Landry Norris

12/29/2022, 9:00 PM
I can;t share my work project, but I can tell you the setup in this project works well for android/ios. https://github.com/LandryNorris/MultiFactor/blob/main/mobileapp/build.gradle.kts
a

Adam Brown

12/29/2022, 9:03 PM
hhmmm ya interesting, so mine isn't just different source sets, its actually different modules: https://github.com/Wavesonics/hammer-editor/
l

Landry Norris

12/29/2022, 9:03 PM
Which module do you see the error in?
a

Adam Brown

12/29/2022, 9:03 PM
android
which includes
composeUi
l

Landry Norris

12/29/2022, 9:04 PM
I noticed you have
api(project(":composeUi"))
a

Adam Brown

12/29/2022, 9:04 PM
ya
l

Landry Norris

12/29/2022, 9:05 PM
I don’t think api brings in transitive dependencies. Try explicitly adding compose.runtime to the dependencies block of the android module.
I also noticed you seem to be mixing compose-jb and jetpack compose in the android module. Try replacing
Copy code
implementation("androidx.compose.ui:ui:$androidx_compose_version")
    implementation("androidx.compose.ui:ui-tooling:$androidx_compose_version")
    implementation("androidx.compose.foundation:foundation:$androidx_compose_version")
    implementation("androidx.compose.material:material:$androidx_compose_version")
    implementation("androidx.compose.material:material-icons-core:$androidx_compose_version")
    implementation("androidx.compose.material:material-icons-extended:$androidx_compose_version")
with the compose-jb equivalents.
a

Adam Brown

12/29/2022, 9:11 PM
ya actually the only one I need there is
activity-compose
removed them but it didn't change anything
l

Landry Norris

12/29/2022, 9:15 PM
What happens if you use implementation instead of API to pull in the compose module?
a

Adam Brown

12/29/2022, 9:16 PM
pushed the latest
Copy code
dependencies {
    implementation(project(":common"))
    implementation(project(":composeUi"))
    api(compose.runtime)
    api(compose.uiTooling)
    api(compose.preview)
    api(compose.foundation)
    api(compose.material)
    //api(compose.material3)
    api(compose.animation)
    api(compose.animationGraphics)
    api(compose.materialIconsExtended)
    implementation("androidx.activity:activity-compose:1.6.1")
}
same error
oh man, very strange, so down in my
common
module, which shouldn't even have any compose in it at all, I added
Copy code
val androidMain by getting {
    dependencies {
        api(compose.runtime) // <- added this
        api("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
        api("io.insert-koin:koin-android:$koin_version")
    }
}
And now it works....
ah i think i see the problem
l

Landry Norris

12/29/2022, 9:48 PM
You have
id("org.jetbrains.compose")
at the top
a

Adam Brown

12/29/2022, 9:48 PM
im applying the compose plugin there
yyuuuppp
artifact of some early hackery
l

Landry Norris

12/29/2022, 9:49 PM
Wherever you have the compose plugin, you have to have the runtime in every compatible target. That includes iOS if you’re on a high enough version of compose-jb. Just add the artifact and ignore it, or remove the plugin.
a

Adam Brown

12/29/2022, 9:49 PM
ya and i had even added it there explicitly for the desktop target
removing the plugin
hey it's all working again!
thanks for your time
414 Views