5

I'm using Jetpack Compose. I have already used it and everything worked fine. I have configured Compose in the app module and in a feature module and in both modules I have imported the same library (see below). When I try to use it in another module, with the same configuration I get the error and all the solutions in here do not apply:

androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.0-rc01) expects a minimum runtime version of 1.0.0-rc01. at androidx.compose.compiler.plugins.kotlin.VersionChecker.outdatedRuntimeWithUnknownVersionNumber(VersionChecker.kt:113) at androidx.compose.compiler.plugins.kotlin.VersionChecker.check(VersionChecker.kt:78) at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:57) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$convertToIr$1.invoke(JvmIrCodegenFactory.kt:120) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$convertToIr$1.invoke(JvmIrCodegenFactory.kt:116) at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:91) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:140) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$default(JvmIrCodegenFactory.kt:66) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:61) at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)

...

I have added the following sections in the build.gradle file of the new module (as for the app module and the first module):

android {
    kotlinOptions {
        jvmTarget = "1.8"
        useIR = true
    }

    composeOptions {
        kotlinCompilerExtensionVersion Version.compose
        kotlinCompilerVersion Version.kotlin
    }

    buildFeatures {
        compose = true
    }
}

dependencies {
    implementation Compose.runtime
    implementation Compose.composeActivity
    implementation Compose.ui
    implementation Compose.material
    implementation Compose.uiTooling
    implementation Compose.livedata
    androidTestImplementation Compose.uiTest
}

where

object Version {
    const val kotlin = "1.5.10"
    const val compose = "1.0.0-rc01"
    const val composeActivity = "1.3.0-rc01"
}

object Compose {
    const val runtime = "androidx.compose.runtime:runtime:${Version.compose}"
    const val composeActivity = "androidx.activity:activity-compose:${Version.composeActivity}"
    const val ui = "androidx.compose.ui:ui:${Version.compose}"
    const val material = "androidx.compose.material:material:${Version.compose}"
    const val uiTooling = "androidx.compose.ui:ui-tooling:${Version.compose}"
    const val uiTest = "androidx.compose.ui:ui-test-junit4:${Version.compose}"
    const val livedata = "androidx.compose.runtime:runtime-livedata:${Version.compose}"
}

The second module in which I'm trying to add Jetpack Compose has many more dependencies. Is it possible that the issue is with one of the dependencies?

kingston
  • 11,053
  • 14
  • 62
  • 116
  • It looks like it has got to do with the dependencies. If I use a third feature module everything is OK. It's only the `core` module with many dependencies that has problems – kingston Jul 06 '21 at 16:49
  • Your kotlin version is not compatable with your compose version. For kotlin version `1.5.10` use `1.0.0-beta09` compose version – Vygintas B Jul 07 '21 at 13:44
  • @VygintasB I followed the setup suggested here: https://developer.android.com/jetpack/compose/setup – kingston Jul 07 '21 at 13:53

1 Answers1

0

It sounds like there is some dependency in the same classpath as your compose dependencies that is bringing another outdated compose version transitively which could result in that failure. A helpful tool which can help you here is: https://github.com/JakeWharton/dependency-tree-diff

Also Note that compose is using a fixed kotlin version under the hood to get their compiler/runtime work, so check that also

MR3YY
  • 638
  • 1
  • 8
  • 18