简体   繁体   中英

Intellisense not working in Kotlin Multiplatform Library

I have a kotlin multiplatofrm library that is included into an Android and iOS app.

In my android project include it as a composite build (MyLib). But Intellisense is not working at all for all code from in MyLib, though the whole thing compiles fine. I am using Android Studio. What could be wrong and how can I debug it?

rootProject.name='xxx'

includeBuild 'MyLib'
include ':common'
include ':app'

MyLib's build.gradle.kts looks as follows:

plugins {
    kotlin("multiplatform") version "1.5.31"
    kotlin("native.cocoapods") version "1.5.31"
}

repositories {
    mavenCentral()
    maven { setUrl("https://dl.bintray.com/kotlin/kotlinx.html/") }
}

group = "com.xxx.MyLib"
// CocoaPods requires the podspec to have a version.
version = "1.0"


kotlin {
    ios()
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "1.8"
        }
        testRuns["test"].executionTask.configure {
            useJUnit()
        }
    }
    cocoapods {
        ios.deploymentTarget = "11.4"
        frameworkName = "MyLib"
        summary = "xxx"
        homepage = "xxx"

        podfile = project.file("../../iOS-App/Podfile")
    }
    sourceSets {
        commonMain {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib:1.5.31")
                implementation("com.badoo.reaktive:reaktive:1.2.0")
                implementation("com.badoo.reaktive:reaktive-annotations:1.2.0")
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.1")
                implementation("com.russhwolf:multiplatform-settings-no-arg:0.8.1")
                implementation("net.swiftzer.semver:semver:1.1.1")
            }
        }
    }
}

tasks.withType<GenerateModuleMetadata> {
    enabled = true
}

I had the same issue and it drove me crazy. How can one write code nowadays without Intellisense (answer: you can't).

I tried a ton of things (all the usual and unusual stuff you do when Android Studio / IntelliJ act up). Ultimately I upgraded to Kotlin 1.6.0-RC2 (from 1.5.31) -> https://github.com/JetBrains/kotlin/releases/tag/v1.6.0-RC2 .

Part of that is upgrading the Kotlin Plugin: 在此处输入图片说明

Another part is the Kotlin Gradle Plugin dependency: org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0-RC2

And last but not least I had to downgrade the corouting dependency (from 1.5.2): org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC

After that everything was back to normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM