Good Morning guys, I am trying to publish kmm libr...
# multiplatform
v
Good Morning guys, I am trying to publish kmm library in my github package. I tried some some code but it giving me error. I am adding my code and error in thread. please guide me thanks.
build.gradle.kts
Copy code
plugins {
    kotlin("multiplatform") version "1.6.21"
    id("com.android.library")
    id("maven-publish")
}

group = "com.abc"
version = "0.0.1"

repositories {
    google()
    mavenCentral()
}

kotlin {
    android {
        publishLibraryVariants("release", "debug")
    }
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    sourceSets {
        val commonMain by getting 
        val androidMain by getting
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
    }
}

android {
    compileSdk = 21
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 21
        targetSdk = 31
    }
    @Suppress("UnstableApiUsage") compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

publishing {
    repositories {
        maven {
            name = "KotlinMultiplatformMobile"
            url = uri("<https://maven.pkg.github.com/Vivek/KotlinMultiplatformMobile>")
            credentials {
                username = "vivek-modi"
                password = "abc"
            }
        }
    }
}
p
You didn't add the error
v
error
when use
./gradlew publish
Copy code
> Task :publishAndroidDebugPublicationToKotlinMultiplatformMobileRepository FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':publishAndroidDebugPublicationToKotlinMultiplatformMobileRepository'.
> Failed to publish publication 'androidDebug' to repository 'KotlinMultiplatformMobile'
   > Could not PUT '<https://maven.pkg.github.com/vivek/KotlinMultiplatformMobile/com/abc/VivekKotlinMultiplatform-android-debug/0.0.1/VivekKotlinMultiplatform-android-debug-0.0.1.aar>'. Received status code 422 from server: Unprocessable Entity
@Paul Woitaschek I added my log
please have alook
g
If you don't want to deal with specific tokens for github api, you may be interested by this plugin , it will create a dedicated branch that will be used as a maven repository. I'm using it here.
👍 1
p
Add a --info to the build and see if there is more to it
lower-case your artifact id
v
where to set artificat id?
p
Google
kotlin artifactid
Second link is a stackoverflow answer
v
Copy code
publications.withType<MavenPublication> {
    artifactId = "com.abc"
}
I set this and getting same error
v
This answer the
name
what he trying to check in if condition? what should I check?
p
Where did you set
ViveKotlinMulti...
?
v
Copy code
publications.withType<MavenPublication> {
    artifactId = if (name == "vivekkotlinmultiplatformmobile") {
        artifactId
    } else {
        "$artifactId-$name"
    }
}
like this?
p
Did you define that
VivekKotlinMulti...
anywhere?
v
I didn't define anywhere, you can check above in
build.gradle.kts
@Paul Woitaschek I added my public github . And same error
Copy code
* What went wrong:
Execution failed for task ':publishKotlinMultiplatformPublicationToKotlinMultiplatfromProjectRepository'.
> Failed to publish publication 'kotlinMultiplatform' to repository 'KotlinMultiplatfromProject'
   > Could not PUT '<https://maven.pkg.github.com/vivek-modi/KotlinMultiplatfromProject/me/vmodi/KotlinMultiplatfromProject-kotlinMultiplatform/1.0.0/KotlinMultiplatfromProject-kotlinMultiplatform-1.0.0.jar>'. Received status code 422 from server: Unprocessable Entity