无法将 Kotlin-android-扩展与 Kotlin/native 一起使用

Unable to use Kotlin-android-extension along with Kotlin/native

我想构建一个同时适用于 ios 和 android 的多平台 Kotlin 模块。但是当我使用

apply plugin: 'kotlin-platform-android'

我无法再解析导入中的 kotlinx。

这是我的androidbuild.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-platform-android'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.phonepe.mykotlinnativesample"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 2
    versionName "2.0"
    testInstrumentationRunner     "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

def butterknife_version = '8.8.1'

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
kapt 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
implementation "com.jakewharton:butterknife:$butterknife_version"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.material:material:1.0.0-alpha3'
expectedBy project(":common")
}

这是我的共同点build.gradle

apply plugin: 'konan'
apply plugin: 'kotlin-platform-common'
repositories {
    mavenCentral()
}

dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib'
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
}
konan.targets = ['iphone', 'iphone_sim']
def frameworkName = 'KotlinHello'
konanArtifacts {
framework(frameworkName)
}
task lipo(type: Exec, dependsOn: 'build') {
def frameworks = files(
            "$buildDir/konan/bin/iphone/${frameworkName}.framework/$frameworkName",
        "$buildDir/konan/bin/iphone_sim/${frameworkName}.framework/$frameworkName"
)
def output = file("$buildDir/konan/bin/iphone_universal/${frameworkName}.framework/$frameworkName")
inputs.files frameworks
outputs.file output
executable = 'lipo'
args = frameworks.files
args += ['-create', '-output', output]
}
task copyFramework(type: Copy, dependsOn: lipo) {
from("$buildDir/konan/bin/iphone") {
    include '*/Headers/*'
    include '*/Modules/*'
    include '*/Info.plist'
}
from "$buildDir/konan/bin/iphone_universal"
into "${rootProject.rootDir}/ios"
}

Kotlin/Native 目前不支持 kapt 或任何其他 kotlinx 库。我们可以在应用程序的 android 平台中使用 kapt,但不能在主要公共模块本身中使用。