JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.98k stars 1.16k forks source link

[Multiplatform] Could not resolve org.jetbrains.compose.runtime:runtime:1.1.0 #1961

Closed oOJohn6Oo closed 2 years ago

oOJohn6Oo commented 2 years ago

I finished a KMM project using Compose on Android Studio, everything is fine. But after I created a desktop module according to the multiplatform-template in this repository, gradle keeps give me this error.

All the artifacts under org.jetbrains.compose could not be resolved.

I've tried many modifications, somethings it works, but I don't know why. I really don't understand what are these pluginManagement, subprojects, allprojects etc. for.

Gradle is driving me crazy

So I was Wondering if there is a sample Multiplatform project include Android, iOS, Desktop and Web for me to refer to?

malliaridis commented 2 years ago

I am using multiple projects for reference. These projects are:

These projects are developed and maintained by experienced developers and contain very interesting concepts, patterns and structures. They use Compose and many other technologies relevant for common projects.

P.S. I hope it's fine mentioning other repositories as an answer.

oOJohn6Oo commented 2 years ago

I am using multiple projects for reference. These projects are:

These projects are developed and maintained by experienced developers and contain very interesting concepts, patterns and structures. They use Compose and many other technologies relevant for common projects.

P.S. I hope it's fine mentioning other repositories as an answer.

Thank you for your help, I compared the projects you listed above with mine, I found that the problem is caused by iOS module.

After I commented out all iOS stuff it worked.

Seems like shared module can only take kotlin/Java module.

But still, why Gradle just give me an error and do not mention a word about this restrict?

Besides, I have to run the Desktop Module in a standalong project, is that normal?

kotlin {
    android()
    jvm("desktop")
//    iosX64()
//    iosArm64()
//    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(compose.runtime)
                implementation(compose.foundation)
                implementation(compose.material)
                implementation(compose.ui)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting
        val androidTest by getting
//        val iosX64Main by getting
//        val iosArm64Main by getting
//        val iosSimulatorArm64Main by getting
//        val iosMain by creating {
//            dependsOn(commonMain)
//            iosX64Main.dependsOn(this)
//            iosArm64Main.dependsOn(this)
//            iosSimulatorArm64Main.dependsOn(this)
//        }
//        val iosX64Test by getting
//        val iosArm64Test by getting
//        val iosSimulatorArm64Test by getting
//        val iosTest by creating {
//            dependsOn(commonTest)
//            iosX64Test.dependsOn(this)
//            iosArm64Test.dependsOn(this)
//            iosSimulatorArm64Test.dependsOn(this)
//        }
    }
}
malliaridis commented 2 years ago

I'm not sure, but I better ask. Do you maybe try to build / run the project for iOS / MacOS on a Windows PC? Because that is not possible due to operating systems limitations.

With that said, you should still be able to build for Android and Windows (on a windows machine) without any issues.

For further reading I can recommend looking into the Multiplatform Gradle DSL reference. There are a lot of sample projects, tutorials and explanations. The section Understand Multiplatform project structures helped me a lot for getting started with gradle files.

I think anything beside that would go too much into detail for troubleshooting and solving your issues, it would require more information about the project structure and the environment you are working in.

oOJohn6Oo commented 2 years ago

I'm not sure, but I better ask. Do you maybe try to build / run the project for iOS / MacOS on a Windows PC? Because that is not possible due to operating systems limitations.

With that said, you should still be able to build for Android and Windows (on a windows machine) without any issues.

For further reading I can recommend looking into the Multiplatform Gradle DSL reference. There are a lot of sample projects, tutorials and explanations. The section Understand Multiplatform project structures helped me a lot for getting started with gradle files.

I think anything beside that would go too much into detail for troubleshooting and solving your issues, it would require more information about the project structure and the environment you are working in.

Yes, I double checked the file structure, found my build.gradle.kts file is in wrong folder.

Now everything's fine.

Thanks.

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.