After adding a common module (followed the multipl...
# compose-desktop
c
After adding a common module (followed the multiplatform compose-jb template) I get this popup, but the full message says this:
Copy code
Compilation is not supported for following modules: rollertoaster.desktop.commonMain, rollertoaster.commoncomposables.androidAndroidTestRelease, rollertoaster.commoncomposables.androidTestFixtures, rollertoaster.commoncomposables.androidTestFixturesDebug, rollertoaster.commoncomposables.androidTestFixturesRelease, rollertoaster.commoncomposables.commonMain, rollertoaster.commoncomposables.commonTest, rollertoaster.commoncomposables.desktopMain, rollertoaster.commoncomposables.desktopTest. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.
Did I setup something incorrectly? Maybe that's the reason why I'm seeing this error? https://github.com/JetBrains/compose-jb/issues/1132
j
is it possible to see a branch with the repro? I am on mobile
c
its my company project, so its internal
j
can you share how kts looks like?
c
of the common module? yeah.
Copy code
import org.jetbrains.compose.compose

plugins {
    id("com.android.library")
    kotlin("multiplatform")
    id("org.jetbrains.compose")
}

kotlin {
    android()
    jvm("desktop")

    sourceSets {
        named("commonMain") {
            dependencies {
                api(compose.runtime)
                api(compose.foundation)
                api(compose.animation)
                api(compose.ui)
                api(compose.uiTooling)
                api(compose.material)
                api(compose.materialIconsExtended)
                implementation(compose("org.jetbrains.compose.ui:ui-util"))
            }
        }
        named("androidMain") {
            dependencies {
                // Compose helpers
                implementation("com.google.accompanist:accompanist-insets:0.19.0")
                implementation("com.google.accompanist:accompanist-pager:0.19.0")
                implementation("com.google.accompanist:accompanist-pager-indicators:0.19.0")

                val coilVersion = "1.4.0"
                implementation("io.coil-kt:coil-compose-base:$coilVersion")
                implementation("io.coil-kt:coil-svg:$coilVersion")
            }
        }
    }
}

android {
    compileSdk = 31

    defaultConfig {
        minSdk = 24
        targetSdk = 30

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles("<http://consumer-rules.pro|consumer-rules.pro>")
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"), "<http://proguard-rules.pro|proguard-rules.pro>")
        }
    }

    lint {
        warningsAsErrors = true
    }

    sourceSets {
        named("main") {
            manifest.srcFile("src/androidMain/AndroidManifest.xml")
            res.srcDirs("src/androidMain/res")
        }
    }

    dependencies {
        lintChecks(project(":lint"))
    }
}
j
implementation(compose("org.jetbrains.compose.ui:ui-util"))
this is strange
why not
implementation("org.jetbrains.compose.ui:ui-util")
and are you sure that that dependency can be used in commonMain and it is not only jvm?
c
Not sure. I think I got that line from @Igor Demin a while back
u
I think you need
implementation(compose("ui-util"))
I am on mobile currently. But jump to the implementation of the
compose
function and it will become clear.
i
The right code is
compose("org.jetbrains.compose.ui:ui-util")
. It will be transformed into
org.jetbrains.compose.ui:ui-util:1.0.0-alpha4-buildXXX
It shouldn't be the reason, why you are seeing
Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project
This error usually happens when you apply
com.android.library
(or
com.android.application
) and
java
plugins in the same module. But your kts file looks fine. Do you have any code in
buildSrc
? Maybe it interferes.
c
No buildSrc! I killed that a few months ago thankfully.
@Igor Demin any other ideas. I just updated to latest AS canary (chipmunk) and saw the popup again and so it reminded me to follow up here.
most of my other modules that are unrelated to sharing common composables have plugin blocks that looks like this
Copy code
plugins {
  id("com.android.library")
  id("kotlin-android")
}
and
Copy code
plugins {
  id("com.android.library")
  id("kotlin-android")
  kotlin("kapt")
  id("dagger.hilt.android.plugin")
  id("org.jetbrains.kotlin.android")
  id("app.cash.exhaustive")
  id("org.jetbrains.compose")
}
and
Copy code
plugins {
  id("com.android.library")
  id("kotlin-android")
  id("org.jetbrains.compose")
}
and
Copy code
plugins {
  id("java-library")
  id("kotlin")
}
and
Copy code
plugins {
  kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio
  // (<https://github.com/JetBrains/compose-jb/issues/22>)
  id("org.jetbrains.compose")
}
i
any other ideas
No, unfortunately. Without a reproducer it is difficult to figure out what is wrong. Your modules look fine.
I just updated to latest AS canary
Is it only AS issue, or
./gradlew assembleRelease
in the console will print the same error?
c
Reached out to the gradle team. they said this is an IDE issue, and not a gradle issue. I wasn't able to resolve whats going on, but I'm going to quit at this for now.