• Gurupad Mamadapur [FH]

    Gurupad Mamadapur [FH]

    2 years ago
    Hi, for some reason I cannot resolve a dependency in the common sourceSet in mpp module. More specifically it is a ktor-core dependency. Here is the build.gradle file -
    plugins {
        id "com.android.library"
        id 'org.jetbrains.kotlin.multiplatform'
    }
    
    repositories {
        mavenCentral()
    }
    
    android {
        compileSdkVersion(28)
        buildToolsVersion = "28.0.3"
        defaultConfig {
            minSdkVersion(16)
            targetSdkVersion(28)
        }
    }
    
    kotlin {
        android()
        js {
            browser {
    
            }
        }
    
        sourceSets {
            commonMain {
                dependencies {
                    implementation kotlin('stdlib-common')
                    implementation "io.ktor:ktor-client-core:$ktorVersion"
                }
            }
            androidMain {
                dependencies {
                    implementation kotlin('stdlib')
                }
            }
            jsMain {
                dependencies {
                    implementation kotlin('stdlib-js')
                }
            }
        }
    }
    Here is the root build.gradle -
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        ext.kotlin_version = '1.3.61'
    
        repositories {
            google()
            mavenCentral()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.3'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    ext {
        ktorVersion = "1.3.0-rc"
    }
    Error is -
    > Task :shared:compileDebugKotlinAndroid FAILED
    e: /Users/fabhotels/Development/testmpp/shared/src/commonMain/kotlin/common.kt: (1, 23): Unresolved reference: HttpClient
    e: /Users/fabhotels/Development/testmpp/shared/src/commonMain/kotlin/common.kt: (3, 18): Unresolved reference: HttpClient
    The sample project is available here - https://github.com/Protino/testmpp/tree/sample/ktor
    Gurupad Mamadapur [FH]
    Kris Wong
    5 replies
    Copy to Clipboard
  • n

    napperley

    2 years ago
    Does Kotlin Multiplatform have a way to share code between multiple Platform modules (eg linuxX64, linuxARMV7) where the OS (eg Linux) is the same?
    n
    ian.shaun.thomas
    +3
    8 replies
    Copy to Clipboard
  • Hannes

    Hannes

    2 years ago
    Hi there, any hint how to call an
    object
    from iOS side? Let's say I have in commonMain a
    object Foo
    How can i call
    Foo
    from iOS side? If I try to use Foo directly I actually somehow access the Type, but not the singleton instance. Any idea?
    Hannes
    kpgalligan
    +2
    4 replies
    Copy to Clipboard
  • jdemeulenaere

    jdemeulenaere

    2 years ago
    How can a Kotlin/JS gradle subproject depend on a Kotlin/Multiplatform subproject ? In my case I have the following gradle project structure:
    client/               <= Kotlin/JS subproject
     |- build.gradle.kts  <= What should I put here to allow client to depend on :shared ?
    server/               <= Kotlin/JVM subproject
     |- build.gradle.kts  <= What should I put here to allow server to depend on :shared ?
    shared/               <= Kotlin/Multiplatform subproject
     |- build.gradle.kts
    I tried to put this but it didn't work:
    dependencies {
        implementation(project(":shared"))
    }
    jdemeulenaere
    egorand
    +1
    10 replies
    Copy to Clipboard
  • ansman

    ansman

    2 years ago
    I’m trying to run the tests for my
    js
    target but I keep getting
    :module:jsTest NO-SOURCE
    . My tests are in
    module/src/jsTest/kotlin
    ansman
    Ilya Goncharov [JB]
    3 replies
    Copy to Clipboard
  • j

    jdiaz

    2 years ago
    Is it possible to share common code between native targets with CInterop working?
    j
    Dominaezzz
    13 replies
    Copy to Clipboard
  • Joey

    Joey

    2 years ago
    * What went wrong:
    A problem occurred evaluating settings 'sample-kt-sharedlib'.
    > Could not find method enableFeaturePreview() for arguments [GRADLE_METADATA] on settings 'sample-kt-sharedlib' of type org.gradle.initialization.DefaultSettings.
    Any suggested solution to this? Im trying to upload a multiplatform lib to bintray. Thanks! 😎
    Joey
    y
    +2
    11 replies
    Copy to Clipboard
  • saket

    saket

    2 years ago
    Are there any technical limitations for not allowing named arguments to members of expected classes?
    saket
    egorand
    2 replies
    Copy to Clipboard
  • Orhan Tozan

    Orhan Tozan

    2 years ago
    Hey guys, we are using Kotlin to build a native Android app, and we are planning to also build an native iOS app. We have a lot of business logic written in Kotlin right now, and its nicely layered, so seperated from the Android framework. I've read about Kotlin Multiplatform and its option to share common logic between different platforms, although after reading more, I'm not sure if our usecase is supported by Kotlin multiplatform. My question and usecase is: is it possible to have a 3 seperate repo setup: core (written in Kotlin), android-app (written in Kotlin) and ios-app (written in Swift). android-app and ios-app both use the core project. So that means that the Core module/repo doesn't know anything about the android/ios project.
    Orhan Tozan
    kpgalligan
    +3
    29 replies
    Copy to Clipboard
  • m

    Marc Knaup

    2 years ago
    Is there a way to run common tests on the JVM using IntelliJ IDEA, ideally with the run icon next to the test? Every time I run a test, it’s running on the JVM but using Gradle. It doesn’t matter than I’ve told the IDEA to not use Gradle for that 😕
    m
    a
    5 replies
    Copy to Clipboard