Does anyone have an example for how to use the nav...
# compose
m
Does anyone have an example for how to use the navigation tutorial? I can find the decompose library but for some reason gradle doesn't seem to like it, and if a working example exists I'd prefer to work from there
l
I’ve been using decompose for a while with no issues. What problems are you seeing?
Here is an example app I made if you want to see a working example. https://github.com/LandryNorris/MemorizePi
m
Specifically, adding the decompose and extensions-compose-jetbrains dependencies give me this gradle error:
org.gradle.api.UncheckedIOException: java.io.InvalidClassException: failed to read class descriptor
l
What version of Gradle and Java are you using? You can get this with ./gradlew --version
m
Copy code
sourceSets {
        val commonMain by getting {
            dependencies {
                api(project(":innertube"))
                api(compose.runtime)
                api(compose.foundation)
                api(compose.material)
                api(compose.ui)
                api(compose.animation)
                api(compose.animationGraphics)
                api("com.arkivanov.decompose:decompose:0.6.0")
                api("com.arkivanov.decompose:extensions-compose-jetbrains:0.6.0")
            }
        }
Here's my gradle config. Gradle 7.4, OpenJDK 17
l
I don’t think I’ve tried 0.6.0 yet. Does 0.5.2 work on your end?
m
Doesn't look like it
Not sure why it suggests the jvm module when this is in common and should work on android too
l
That is odd.
m
Full build.gradle.kts:
Copy code
import org.jetbrains.compose.compose

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

group = "com.mewsic"
version = "1.0"

kotlin {
    android()
    jvm("desktop") {
        compilations.all {
            kotlinOptions.jvmTarget = "11"
        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                api(project(":innertube"))
                api(compose.runtime)
                api(compose.foundation)
                api(compose.material)
                api(compose.ui)
                api(compose.animation)
                api(compose.animationGraphics)
                api("com.arkivanov.decompose:decompose:0.5.2")
                api("com.arkivanov.decompose:extensions-compose-jetbrains:0.5.2")
            }
        }
        val androidMain by getting {
            dependencies {
                api("androidx.appcompat:appcompat:1.4.1")
                api("androidx.core:core-ktx:1.7.0")
            }
        }
        val desktopMain by getting {
            dependencies {
                api(compose.preview)
            }
        }
    }
}

android {
    compileSdk = 31
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 24
        targetSdk = 31
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}
l
Do you currently have anything else depending on commonMain? If you don't it will only be jvm.
m
Both androidMain and desktopMain implicitly depend on it, and so do the separate android and desktop folders
and removing the -jvm to get a multiplatform library doesn't work either
l
Ok. Both of those are presumably jvm, so commonMain allows anything on the jvm. That's why it suggested the jvm version.
m
But then how will I support ios when I get around to buying a mac?
l
Add an iosMain now, and it will change commonMain to require that code is good for Android, iOS, and jvm.
a
What is the Kotlin version?
l
Try a gradle clean? If that doesn't work, delete the .gradle folder (specifically .gradle, not gradle) and rebuild.
m
Kotlin version is 1.6.10, already tried deleting the .gradle folder
l
Just confirmed that 0.6.0 works on my project.
m
Adding an ios() configuration gives this error:
Copy code
Could not determine the dependencies of task ':commonizeNativeDistribution'.
> Could not resolve all files for configuration ':kotlinKlibCommonizerClasspath'.
   > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.6.10 because no repositories are defined.
     Required by:
         project :
The strange thing is that parcelable is definitely on classpath, maybe it's just that intellij doesn't detect it?
a
You depend on Compose in common, I think you can't add the ios target. What is the compose version btw?
Also, which distribution of compose is used - Jetpack or MPP?
m
I'm using MPP I think? version 1.0.1
I think you can't add the ios target
Doesn't Jetbrains Compose support ios too?
l
The latest alpha does (1.2.0-alpha01-dev620)
But for now, I'd use it In a jvmMain that both android and desktop depend on.
a
extensions-compose-jetbrains depends on Compose 1.1.0, could you please try setting this version?
m
looks like the class does exist but the IDE doesn't see it until I import it directly
a
You may try deleting the .idea folder and reopening the project, it often helps