Thread
#multiplatform
    krtko

    krtko

    2 years ago
    Hey I haven't used Kotlin MPP since they did their major redesign of the project structure and I can't seem to figure it out. I just want to add a Kotlin-only MPP module to my Android app and failing horribly. Heres the
    build.gradle.kts
    file for the new module
    plugins {
        kotlin("multiplatform")
    }
    
    kotlin {
        targets {
            targetFromPreset(presets.getByName("jvm"), "android")
        }
        sourceSets {
            commonMain {
                dependencies {
                    implementation("org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61")
                }
            }
            getByName("androidMain") {
                dependencies {
                    implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.61")
                }
            }
        }
    }
    Everything builds fine, but my Android module can't see the kotlin MPP one
    s

    sikri

    2 years ago
    You have to add android settings in mpp, module:1. add
    id("com.android.library")
    to plugins {} 2. add android settings:
    android {
        compileSdkVersion(29)
        buildToolsVersion = "29.0.2"
        defaultConfig {
            minSdkVersion(16)
            targetSdkVersion(29)
        }
        sourceSets {
            val main by getting { setRoot("src/androidMain") }
        }
    }
    3. create directory
    src/androidMain
    with some empty
    AndroidManifest.xml
    inside it. Now it should work
    Btw, do you actually need android source set? if it is kotlin-only module, maybe it would be better for you to stick with jvm only?
    krtko

    krtko

    2 years ago
    As of right now I do not need an Android source set
    Sorry just trying to figure out how to make this all work these days
    So if I was to just add a JVM source set what would that look like?
    Ok figured it out
    Thank you