icerockdev / moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
997 stars 95 forks source link

Problem to install dependencies #102

Closed joavilati closed 3 years ago

joavilati commented 3 years ago

I am trying to install some moko dependencies and getting this error.

org.gradle.internal.resolve.ArtifactNotFoundException: Could not find mvvm-livedata-0.9.1-samplessources.jar (dev.icerock.moko:mvvm-livedata:0.9.1). Searched in the following locations: https://dl.bintray.com/icerockdev/moko/dev/icerock/moko/mvvm-livedata/0.9.1/mvvm-livedata-0.9.1-samplessources.jar

it looks like the "-samplessources" part of the link shouldn't be there, but a don't know how to remove it.

image

image

Alex009 commented 3 years ago

Hi! Can you run ./gradlew build from terminal and copy all output?

And what kotlin targets enabled?

joavilati commented 3 years ago

No matching variant of dev.icerock.moko:mvvm-core:0.9.1 was found. The consumer was configured to find an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:

  • Variant 'commonMainMetadataElements-published' capability dev.icerock.moko:mvvm-core:0.9.1:
  • Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'debugApiElements-published' capability dev.icerock.moko:mvvm-core:0.9.1 declares an API of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'debugRuntimeElements-published' capability dev.icerock.moko:mvvm-core:0.9.1 declares a runtime of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'iosArm64ApiElements-published' capability dev.icerock.moko:mvvm-core:0.9.1:
  • Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'iosArm64MetadataElements-published' capability dev.icerock.moko:mvvm-core:0.9.1:
  • Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'iosX64ApiElements-published' capability dev.icerock.moko:mvvm-core:0.9.1:
  • Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'iosX64MetadataElements-published' capability dev.icerock.moko:mvvm-core:0.9.1:
  • Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'metadataApiElements-published' capability dev.icerock.moko:mvvm-core:0.9.1:
  • Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'releaseApiElements-published' capability dev.icerock.moko:mvvm-core:0.9.1 declares an API of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
  • Variant 'releaseRuntimeElements-published' capability dev.icerock.moko:mvvm-core:0.9.1 declares a runtime of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'

Screen Shot 2021-01-26 at 10 45 09 Screen Shot 2021-01-26 at 10 45 55 Screen Shot 2021-01-26 at 10 46 27 Screen Shot 2021-01-26 at 10 46 57

Alex009 commented 3 years ago

you use target jvm but moko-mvvm supports only android & ios targets for now. you can separate mobile targets from jvm by creating additional sourceset for example mobileMain like this - https://github.com/icerockdev/moko-resources/issues/133#issuecomment-740700058

joavilati commented 3 years ago

Thank you! When i tried this and gradle got the libraries, but now I can not use on code.

*.shared.viewmodel

image image

even when i manually import the class.

`sourceSets { val commonMain by getting { dependencies { api(Deps.Decompose.decompose) api(Deps.coroutines)

            implementation(Deps.ktxSerializationJson)
            implementation(Deps.ktorCore)
            implementation(Deps.ktorSerialization)
            implementation(Deps.kissMeCommon)
        }
    }
    val commonTest by getting {
        dependencies {
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))

        }
    }
    val mobileMain by creating {
        dependsOn(commonMain)
        dependencies {
            api("dev.icerock.moko:mvvm-core:0.9.1")
            api("dev.icerock.moko:mvvm-livedata:0.9.1")
        }
    }

    val androidMain by getting {
        dependencies {
            implementation("com.google.android.material:material:1.2.1")
            implementation(Deps.ktorAndroid)
            implementation(Deps.kissMeAndroid)
        }
    }
    val androidTest by getting {
        dependencies {
            implementation(kotlin("test-junit"))
            implementation("junit:junit:4.13")
        }
    }
    val iosMain by getting {
        dependencies {
            implementation(Deps.ktorIOS)
            implementation(Deps.kissMeIOS)
        }
    }
    val iosTest by getting
    val jvmMain by getting {
        dependencies {
            implementation("io.ktor:ktor-client-okhttp:1.4.2")
        }
    }

    named("iosX64Main") {
        dependencies {
            api(Deps.Decompose.iosX64)
        }
    }

    named("iosArm64Main") {
        dependencies {
            api(Deps.Decompose.iosArm64)
        }
    }
}`
joavilati commented 3 years ago

I chose to remove the jvm as target, and that solved. Thank you for your help