无法将多平台项目的Kotlin更新到v1.3.50

时间:2019-10-03 07:11:17

标签: kotlin kotlin-multiplatform

我正在为多平台项目(包括1.3.41iosjvm)使用kotlin js,一切正常。现在,我尝试更新到最新版本1.3.50,但出现此错误:

Could not determine the dependencies of task ':kotlinNpmInstall'.
> org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager$ResolutionState$Installed cannot be cast to org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager$ResolutionState$Configuring

我尝试在任何地方搜索(github,kotlin问题跟踪器),但一无所获。有人知道导致此错误的原因吗?谢谢。

部分配置:

  

根项目配置

buildscript {
  apply from: "buildsystem/dependencies.gradle"

  repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://dl.bintray.com/kotlin/kotlinx/" }
    maven { url "https://plugins.gradle.org/m2/" }
  }

  dependencies {
    classpath deps.gradlePlugins.android
    classpath deps.gradlePlugins.androidNavigation
    classpath deps.gradlePlugins.node
    classpath deps.gradlePlugins.kotlin
    classpath deps.gradlePlugins.kotlinSerialization
    classpath deps.gradlePlugins.kotlinAtomicfun
    classpath deps.gradlePlugins.dokka
  }
}
  

多平台模块配置

apply plugin: 'org.jetbrains.kotlin.multiplatform'

apply plugin: 'kotlinx-serialization'

kotlin {
  targets {
    jvm("jvm")
    js("js") {
      nodejs {}
    }
    iosArm64("ios64")
    iosX64("iosSim")
    configure([ios64, iosSim]) {
      binaries.framework {
        baseName = "LIB"
      }
    }
  }

  sourceSets {
    def commonDependencies = rootProject.ext.deps.common
    commonMain {
      dependencies {
        implementation commonDependencies.kotlin
        implementation commonDependencies.kotlinCoroutines
      }
    }
    commonTest {
      dependencies {
        implementation commonDependencies.kotlinTest
        implementation commonDependencies.kotlinTestAnnotations
        implementation commonDependencies.mockk
      }
    }

    def jvmDependencies = rootProject.ext.deps.jvm
    jvmMain {
      dependencies {
        implementation jvmDependencies.kotlin
        implementation jvmDependencies.kotlinCoroutines
      }
    }
    jvmTest {
      dependencies {
        implementation jvmDependencies.kotlinTest
        implementation jvmDependencies.kotlinTestJunit
        implementation jvmDependencies.kotlinCoroutinesTest
        implementation jvmDependencies.mockk
      }
    }

    def jsDependencies = rootProject.ext.deps.js
    jsMain {
      dependencies {
        implementation jsDependencies.kotlin
        implementation jsDependencies.kotlinCoroutines
        // npm
        implementation npm("uuid", "^3.3.2")
      }
    }
    jsTest {
      dependsOn jsMain
      dependsOn commonMain
      dependencies {
        implementation jsDependencies.kotlinTest
      }
    }

    def iosDependencies = rootProject.ext.deps.ios
    iosMain {
      dependencies {
        implementation iosDependencies.kotlinCoroutines
      }
    }

    ios64Main {
      dependsOn iosMain
    }

    iosSimMain {
      dependsOn iosMain
    }
  }
}
// other configuration

1 个答案:

答案 0 :(得分:0)

我可以确认问题出在Android Studio中。

当我在IntelliJ上运行官方KotlinJS react app tutorial时,该应用程序将运行。但是在AS上,执行任何依赖于npm的Gradle任务时,都会出现上述错误。

在问题解决之前,我建议您使用IntelliJ的社区版本。您可以here下载它