https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
t

Tiago Nunes

03/28/2021, 1:29 AM
Hi, I'm new to KMP/KMM, I was trying to add an Android module to an existing KMP project (copying from the compose-multiplatform sample from IntelliJ IDEA). The structure is as follows: • android module • webBackend module • common module ◦ commonMain ◦ commonTest ◦ androidMain ◦ androidTest ◦ webBackendMain ◦ webBackendTest From what I understood from the sample, I'm supposed to create an android library in the common module, which will contain the "actual"s. I tried doing so, but I get this error when syncing the project: No variants found for 'common'. Check build files to ensure at least one variant exists. Does anyone know what could be happening? I'm trying to find answers for hours, but the setup looks exactly like the sample, yet the sample syncs and my project doesn't... commom/build.gradle.kts:
Copy code
plugins {
    kotlin("multiplatform")
    id("com.android.library")
}

group = "me.tnunes"
version = "1.0-SNAPSHOT"

kotlin {
    android {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
                useIR = true
            }
        }
    }
    jvm("webBackend") {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
                useIR = true
            }
        }
    }
    sourceSets {
        val commonMain by getting
        val commonTest by getting
        val webBackendMain by getting
        val webBackendTest by getting
        val androidMain by getting {
            dependencies {
                api("androidx.core:core-ktx:1.3.2")
                api("androidx.appcompat:appcompat:1.2.0")
                api("androidx.constraintlayout:constraintlayout:2.0.4")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation("junit:junit:4.13.2")
            }
        }
    }
}

android {
    compileSdkVersion(30)
    buildToolsVersion("30.0.3")
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(23)
        targetSdkVersion(30)
    }
}
After trying in Android Studio Arctic Fox and setting the base projects' SDK, it started working...