question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom common source set crash at configuration time

See original GitHub issue

Hey! I want to use it in my project, but it not adding in to the project:

<ij_msg_gr>Gradle import errors<ij_msg_gr><ij_nav>D:\Projects\KotlinMultiplatformMobile\example\shared\build.gradle.kts<ij_nav><i><b>project ':shared': Unable to build Kotlin project configuration</b><eol>Details: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find resources-0.13.1-samplessources.jar (dev.icerock.moko:resources:0.13.1).<eol>Searched in the following locations:<eol>    https://dl.bintray.com/icerockdev/moko/dev/icerock/moko/resources/0.13.1/resources-0.13.1-samplessources.jar</i>```

run "gradlew build --info", I getting error:

```Execution failed for task ':shared:compileKotlinJvm'.
> Could not resolve all files for configuration ':shared:jvmCompileClasspath'.
   > Could not resolve dev.icerock.moko:resources:0.13.1.
     Required by:
         project :shared
      > No matching variant of dev.icerock.moko:resources:0.13.1 was found. The consumer was configured to find an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'android-debugApiElements' capability dev.icerock.moko:resources:0.13.1 declares an API of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value '
jvm'
          - Variant 'android-debugRuntimeElements' capability dev.icerock.moko:resources:0.13.1 declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value '
jvm'
          - Variant 'android-releaseApiElements' capability dev.icerock.moko:resources:0.13.1 declares an API of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value '
jvm'
          - Variant 'android-releaseRuntimeElements' capability dev.icerock.moko:resources:0.13.1 declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value '
jvm'
          - Variant 'iosArm64-api' capability dev.icerock.moko:resources:0.13.1:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.k
otlin.platform.type' with value 'jvm'
          - Variant 'iosArm64-iosArm64MetadataElements' capability dev.icerock.moko:resources:0.13.1:
              - Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbra
ins.kotlin.platform.type' with value 'jvm'
          - Variant 'iosX64-api' capability dev.icerock.moko:resources:0.13.1:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.k
otlin.platform.type' with value 'jvm'
          - Variant 'iosX64-iosX64MetadataElements' capability dev.icerock.moko:resources:0.13.1:
              - Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbra
ins.kotlin.platform.type' with value 'jvm'
          - Variant 'metadata-api' capability dev.icerock.moko:resources:0.13.1:
              - Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbra
ins.kotlin.platform.type' with value 'jvm'
          - Variant 'metadata-commonMainMetadataElements' capability dev.icerock.moko:resources:0.13.1:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.k
otlin.platform.type' with value 'jvm'
    val kotlin_version: String by extra
    val shadow_version: String by extra
    repositories {
        gradlePluginPortal()
        jcenter()
        google()
        mavenCentral()
        maven("https://kotlin.bintray.com/kotlinx")
        maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies")
        maven("https://dl.bintray.com/kotlin/kotlin-dev")
        maven("https://dl.bintray.com/icerockdev/plugins")
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20")
        classpath("com.android.tools.build:gradle:4.1.1")
        classpath("com.github.jengelman.gradle.plugins:shadow:$shadow_version")
        classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlin_version")
        classpath("dev.icerock.moko:resources-generator:0.13.1")
    }
}

allprojects {
    repositories {
        mavenLocal()
        mavenCentral()
        google()
        jcenter()
        maven("https://dl.bintray.com/kotlin/kotlinx")
        maven("https://dl.bintray.com/kotlin/ktor")
        maven("https://dl.bintray.com/sargunster/maven")
        maven("https://dl.bintray.com/kotlin/squash")
        maven("https://oss.sonatype.org/content/repositories/snapshots/")
        maven("https://dl.bintray.com/kotlin/kotlin-dev")
        maven("https://kotlin.bintray.com/kotlinx")
        maven("https://dl.bintray.com/florent37/maven")
        maven("https://dl.bintray.com/ekito/koin")
        maven("https://dl.bintray.com/icerockdev/moko")
    }
}```


```import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

val ideaActive = true
plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("kotlinx-serialization")
    id("dev.icerock.mobile.multiplatform-resources")
}
group = "com.example.test"
version = "1.0"

val kotlin_version: String by extra
val ktor_version: String by extra
val coroutines_version: String by extra
val serialization_version: String by extra
val android_mapbox: String by project
val setting_version: String by project

android {
    java {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    compileSdkVersion(30)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(30)
        versionCode = 1
        versionName = "1.0"
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
}

kotlin {
    jvm()
    android()
    ios {
        binaries {
            binaries.framework {
                baseName = "KotlinShared"
                isStatic = true
                transitiveExport = true
            }
        }
    }

    val iosArm32 = iosArm32("iosArm32")

    if (ideaActive) {
        iosX64("ios")
    }

    sourceSets {
//        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }

        val commonMain by getting {
            dependencies {

                implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
                implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")

                implementation("io.ktor:ktor-client-core:$ktor_version")
                implementation("io.ktor:ktor-client-auth:$ktor_version")
                implementation("io.ktor:ktor-client-logging:$ktor_version")
                implementation("ch.qos.logback:logback-classic:1.2.1")
                implementation("io.ktor:ktor-client-serialization:$ktor_version")

                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC")
                implementation("org.koin:koin-core:3.0.0-alpha-4")
                implementation("dev.icerock.moko:resources:0.13.1")
            }
        }
        multiplatformResources {
            multiplatformResourcesPackage = "com.example.test"
            multiplatformResourcesSourceSet = "commonMain"  // optional, default "commonMain"
        }

        val jvmMain by getting {
            dependencies {
                api("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
                api("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version")
                api("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
                api("io.ktor:ktor-client-serialization-jvm:$ktor_version")
                api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
                api("io.ktor:ktor-client-core-jvm:$ktor_version")
                api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
            }
        }

        val androidMain by getting {
            dependsOn(commonMain)
            dependsOn(jvmMain)
            dependencies {
                implementation("com.google.android.material:material:1.2.1")
                implementation("io.ktor:ktor-client-okhttp:1.3.2")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13")
            }
        }
        val iosTest by getting

        val iosMain = if (ideaActive) {
            getByName("iosMain")
        } else {
            create("iosMain")
        }

        iosMain.apply {
            dependsOn(commonMain)

            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC")

                implementation("io.ktor:ktor-client-ios:1.4.0")
                implementation("io.ktor:ktor-client-serialization:$ktor_version")

                api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.20")
            }
        }
    }

    //Build tasks for fat frameworks
    val iosArm64 = targets.getByName<KotlinNativeTarget>("iosArm64")
    val iosX64 = targets.getByName<KotlinNativeTarget>("iosX64")
    tasks.register<org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask>("debugFatFramework") {
        group = "ios"
        baseName = "KotlinShared"
        description = "Builds a universal (fat) debug framework"

        from(targets("DEBUG", iosArm64, iosX64))
    }
    tasks.register<org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask>("releaseFatFramework") {
        group = "ios"
        baseName = "KotlinShared"
        description = "Builds a universal (fat) release framework"

        from(targets("RELEASE", iosArm64, iosX64))
    }
}

fun targets(
    type: String,
    vararg targets: KotlinNativeTarget
): List<org.jetbrains.kotlin.gradle.plugin.mpp.Framework> {
    return targets.map {
        it.binaries.getFramework(type)
    }
}

val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val framework =
        kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)
    val targetDir = File(buildDir, "xcode-frameworks")
    from({ framework.outputDirectory })
    into(targetDir)
}

tasks.getByName("build").dependsOn(packForXcode)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Alex009commented, Dec 29, 2020

fixed in 0.14.0. will be released on this week

0reactions
mustafaozhancommented, Dec 30, 2020

Thanks a lot! 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

The System is Crashing - Oracle Help Center
The most common cause for a code generation crash is a mis-compiled method. If the JRockit JVM mis-compiles a method, either the JVM...
Read more >
Customize your Firebase Crashlytics crash reports - Google
This guide describes how to customize your crash reports using the Firebase Crashlytics SDK. By default, Crashlytics automatically collects crash reports for ...
Read more >
Understanding the exception types in a crash report
The exception type in a crash report describes how the app terminated. It's a key piece of information that guides how to investigate...
Read more >
Troubleshooting : WebSphere start/stop common issues - IBM
Java could be corrupted. · Invalid JVM arguments are set on the application server JVM. · The startServer launcher could be crashing.
Read more >
Chapter 7. Kernel crash dump guide - Red Hat Customer Portal
Starting with Red Hat Enterprise Linux 7.1, kdump configuration has been moved into the installer. Some installation options, such as custom Kickstart ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found