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

ribesg

01/28/2019, 10:57 AM
What makes
compilations
of an
android
target appear?
Copy code
repositories {
    jcenter()
}

plugins {
    id("com.android.application") version "3.3.0"
    kotlin("multiplatform") version "1.3.20"
    kotlin("android.extensions") version "1.3.20"
    kotlin("kapt") version "1.3.20"
}

android {

    compileSdkVersion(28)

    defaultConfig {

    }

    sourceSets {
        getByName("main").java.srcDir("src/androidMain/kotlin")
        getByName("test").java.srcDir("src/androidTest/kotlin")
    }

    buildTypes {
        getByName("release") {

        }
        getByName("debug") {

        }
    }

}

kotlin {
    android {
        println(compilations.asMap)
    }
    iosArm64 {
        println(compilations.asMap)
    }
    iosX64 {
        println(compilations.asMap)
    }
    sourceSets {
        val commonMain by getting {

        }
        val commonTest by getting {

        }
        val androidMain by getting {

        }
        val androidTest by getting {

        }
        val iosMain by creating {

        }
        val iosTest by creating {

        }
        val iosArm64Main by getting {
            dependsOn(iosMain)
        }
        val iosArm64Test by getting {
            dependsOn(iosTest)
        }
        val iosX64Main by getting {
            dependsOn(iosMain)
        }
        val iosX64Test by getting {
            dependsOn(iosTest)
        }
    }
}
Prints:
Copy code
{}
{main=compilation 'main' (target iosArm64 (native)), test=compilation 'test' (target iosArm64 (native))}
{main=compilation 'main' (target iosX64 (native)), test=compilation 'test' (target iosX64 (native))}
Why is the Android
compilations
empty? I’ve got buildTypes and all
d

Dominaezzz

01/28/2019, 2:01 PM
Are build variants and build types the same?
I think you need to create a product flavour.
r

ribesg

01/28/2019, 2:28 PM
No and no, variants are the multiplication of types and flavours. For example if I have 2 types and 2 flavors I have 4 variants. In my case I have the 2 default build types (debug & release) and the “default flavor” which is none, so I should have 2 variants
When using the variant filter I see the two variants but when printing the
applicationVariants
it’s empty