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

huangapple go评论51阅读模式
英文:

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

问题

以下是您要翻译的代码部分:

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
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
    }
}

希望这对您有所帮助。如果您需要进一步的协助,请随时告诉我。

英文:

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.

答案1

得分: 0

最终在升级依赖项后解决了问题。

不确定是哪个依赖项造成的。最终进行了升级:

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

之后又进行了如下升级:

  • kotlin 多平台(1.8.20-RC)

我始终无法使 Android Native 正常工作,并已将其注释掉。

英文:

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.

huangapple
  • 本文由 发表于 2023年2月10日 05:25:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75404560.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定