cj-
cj-

Reputation: 322

Kotlin/Native `Could not find :kotlin-native-prebuilt-windows-x86_64`

My goal is to make a Kotlin Multiplatform module for Android and iOS. It is being built using Gradle as a dependency of an Android app on Windows. When only Android is a target it builds just fine, but if any native targets are added it fails:

Could not resolve all dependencies for configuration ':shared-mobile-lib:detachedConfiguration3'.
The project declares repositories, effectively ignoring the repositories you have declared in the settings.
You can figure out how project repositories are declared by configuring your build to fail on project repositories.

Could not find :kotlin-native-prebuilt-windows-x86_64:1.7.10.
Required by:
    project :shared-mobile-lib

How do I fix this?

Here is the build.gradle.kt:

plugins {
    kotlin("multiplatform")
    id("com.android.library")
}

repositories {
    google()
    mavenCentral()
}

group = "com.agragps.mobile"
version = "0.1.0"

kotlin {
    android()
    // The below targets fail
    iosArm32 {
        binaries {
            framework {
                baseName = "library"
            }
        }
    }
    iosArm64 {
        binaries {
            framework {
                baseName = "library"
            }
        }
    }
    iosX64 {
        binaries {
            framework {
                baseName = "library"
            }
        }
    }
    androidNativeArm64()
    androidNativeArm32()
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("com.google.android.material:material:1.8.0")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation("junit:junit:4.13.2")
            }
        }
        val iosArm32Main by getting
        val iosArm32Test by getting
        val iosArm64Main by getting
        val iosArm64Test by getting
        val iosX64Main by getting
        val iosX64Test by getting
        val androidNativeArm64Main by getting
        val androidNativeArm64Test by getting
        val androidNativeArm32Main by getting
        val androidNativeArm32Test by getting
    }
}

android {
    compileSdkVersion(33)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(21)
        targetSdkVersion(33)
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
}

This is based on a sample project from Intellij IDEA, I verified Kotlin Native was installed under .konan and tried configuring the build to fail for project repositories (the repository specified is ivy) with no luck.

Upvotes: 1

Views: 1298

Answers (1)

cj-
cj-

Reputation: 322

Eventually worked after upgrading dependencies.

Not sure which dependency it was. Ended up upgrading:

  • Gradle (7.4.2 -> 8.0.2)
  • com.android.tools.build:gradle (7.0.4 -> 7.4.2)

And later:

  • kotlin multiplatform (1.8.20-RC)

I was never able to get Android Native working and have it commented out.

Upvotes: 0

Related Questions