gpt4 book ai didi

android - 添加 Kotlin Multiplatform 模块作为依赖项时出错 : "Android project without build variants, and cannot be built."

转载 作者:行者123 更新时间:2023-12-03 05:04:21 36 4
gpt4 key购买 nike

我正在尝试将 Kotlin-Multiplatform 库添加为 Android 项目的依赖项。我收到以下错误:

ERROR: The module 'my-core' is an Android project without build variants, and cannot be built. Please fix the module's configuration in the build.gradle file and sync the project again.



'my-core' Kotlin-Multiplatform 库的 build.gradle 如下:
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.squareup.sqldelight:gradle-plugin:1.3.0'
classpath 'com.android.tools.build:gradle:3.6.3'
}
}

plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.72'
}
repositories {
mavenCentral()
jcenter()
google()
}

def ktor_version = '1.3.2'
def sqldeligh_version = '1.3.0'

group 'com.zoho.im.core'
version '0.0.1'

apply plugin: 'com.squareup.sqldelight'
apply plugin: 'maven-publish'
apply plugin: 'com.android.library'

android {
compileSdkVersion(29)
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionCode = 1
versionName = "0.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

//This is for MultiplatformSettings
debug {
// MPP libraries don't currently get this resolution automatically
matchingFallbacks = ['release']
}
}
}

kotlin {
android()
// This is for iPhone simulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("ios") {
binaries {
framework()
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
androidMain {
dependencies {
implementation kotlin('stdlib')
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
implementation "com.squareup.sqldelight:android-driver:$sqldeligh_version"
}
}
iosMain {
dependencies {
implementation "io.ktor:ktor-client-ios:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
implementation "com.squareup.sqldelight:native-driver:$sqldeligh_version"
}
}
}
}

sqldelight {
IMDatabase {
packageName = "com.harley.core"
}
}

configurations {
compileClasspath
}

我导入的android项目只是一个简单的新鲜项目。请指教

最佳答案

这可能是因为您在 commonMain 源集中具有 native 依赖项:io.ktor:ktor-client-serialization-native:$ktor_version元数据系统将无法为此依赖项找到合适的目标,这可能会导致您演示的错误。这只是我的猜测。

关于android - 添加 Kotlin Multiplatform 模块作为依赖项时出错 : "Android project without build variants, and cannot be built.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62035206/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com