Hello I've created from android studio + plugin a ...
# multiplatform
i
Hello I've created from android studio + plugin a hello world library (not app), which contains the "Greeting.kt" basic class. I want to publish it locally via maven (publishToMavenLocal). The publishing happens, the folder is created along the .pom. But no artifact at all is created, meaning no .aar nor .framework files are created. What am I missing?
Copy code
plugins {
    //trick: for the same plugin versions in all sub-modules
    id("com.android.library").version("8.0.1").apply(false)
    kotlin("multiplatform").version("1.8.10").apply(false)
    id("maven-publish")
}

tasks.register("clean", Delete::class) {
    delete(rootProject.buildDir)
}

publishing {
    publications {
        create<MavenPublication>("release") {
            groupId = "com.ion.testkmm"
            artifactId = "testkmmion"
            version = "1.0"
        }
    }
}
l
There's something you have to add to the android target config to publish for android. I'm on mobile now, but I'll see if I can find it. What targets have you set up?
c
maven-publish
needs to be applied to each submodule individually, not in the root project
l
Copy code
android { 
         publishLibraryVariants("debug", "release") 
     }
You'll need this when you set up the android target. I think there's a new gradle 8.0+ way, but this is what I've used.
i
Copy code
android {
    namespace = "com.ion.testkmm"
    compileSdk = 33
    defaultConfig {
        minSdk = 24
    }

    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }

    publishing {
        singleVariant("release")
    }
}

publishing {
    publications {
        create<MavenPublication>("release") {
            groupId = "com.ion.testkmm"
            artifactId = "testkmmion" //this is the "shared", that has been renamed
            version = "1.0"
        }
    }
}
still nothing, althought it created everyfolder like: testkmm, testkmm-android, testkmm-ios
Copy code
kotlin {
    android {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
        publishLibraryVariants("release")
    }
    
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "testkmmion"
        }
    }

    sourceSets {
...