This message was deleted.
# community-support
s
This message was deleted.
r
here is my full shared/build.gradle
Copy code
plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.kotlinCocoapods)
    alias(libs.plugins.androidLibrary)
    alias(libs.plugins.mavenPublish)
}

mavenPublishing {
    publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.S01)
    signAllPublications()
    coordinates("com.raedghazal", "kotlinx_datetime_ext", "1.0.1")

    pom {
        name.set("Kotlinx datetime ext")
        description.set("A KMM library that provides extensions and helper functions for kotlinx-datetime ")
        inceptionYear.set("2023")
        url.set("<https://github.com/RaedGhazal/kmm-kotlinx-datetime-ext>")
        developers {
            developer {
                id.set("RaedGhazal")
                name.set("Raed Ghazal")
                url.set("<https://github.com/RaedGhazal>")
            }
        }
        licenses {
            license {
                name.set("MIT License")
                url.set("<https://opensource.org/license/mit/>")
                distribution.set("<https://opensource.org/license/mit/>")
            }
        }
        scm {
            url.set("<https://github.com/RaedGhazal>")
            connection.set("scm:git:<git://github.com/RaedGhazal/kmm-kotlinx-datetime-ext.git>")
            developerConnection.set("scm:git:<ssh://git@github.com/RaedGhazal/kmm-kotlinx-datetime-ext.git>")
        }
    }
}

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "16.0"
        framework {
            baseName = "shared"
            isStatic = true
        }
    }
    
    sourceSets {
        commonMain.dependencies {
            implementation(commonlibs.kotlinx.datetime)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
    }
}

android {
    namespace = "com.raedghazal.kotlinx_datetime_ext"
    compileSdk = 34
    defaultConfig {
        minSdk = 26
    }
}
dependencies {
    implementation(commonlibs.androidx.core.ktx)
}
and the error starts with something like this
Copy code
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.raedghazal:kotlinx_datetime_ext:1.0.1.
     Required by:
         project :app > project :shared
      > No matching variant of com.raedghazal:kotlinx_datetime_ext:1.0.1 was found. The consumer was configured to find a component for use during runtime, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.1.0', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - Variant 'iosArm64ApiElements-published' capability com.raedghazal:kotlinx_datetime_ext:1.0.1:
              - Incompatible because this component declares a component for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component for use during runtime, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.1.0')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
there is 198 instances of
- Variant
162 are
iosSomething
and 36 are
metadataSomething
none about android so apparently its trying to find android but not able to find it releasing to mavenLocal shows this in m2 folder/library/version number 👇
v
Yep, as you can see in your module file, you only publish iOS variants:
I don't think
androidTarget
is what you wanted to use. Have a look at https://kotlinlang.org/docs/multiplatform-publish-lib.html#publish-an-android-library
r
ah right wanted to test with publishLibraryVariants(“release”, “debug”) but then forgot about it
but thanks! let me try
v
Maven Central
r
Yes
r
ah, I was trying to find it but didn’t know which file, thanks as well
looks like the error is gone, still building but previously it used to show immediately
👌 1
v
ah, I was trying to find it but didn’t know which file, thanks as well
https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html
Also you should consider using a composite build instead of the doomed Maven Local whenever possible 🙂
r
wdym? I just used maven local to try to fix the issue locally without publishing to maven central everytime
v
If you don't know what a composite build is, you don't understand. Learn what a composite build is and you will very much enjoy using it for the local development instead of Maven Local 😉
r
yeah unfortunately I’m not very experienced in the libraries side of android 😅 this is my first library, mainly creating it for learning purposes, and also its probably useful for other developers. but will check that out, thank you for pointing 🙏
👌 1