我想构建一个Kotlin
适用于安卓和安卓的多平台模块ios
。但是当我使用
apply plugin: 'kotlin-platform-android'
我不再能够在我的导入中解析 kotlinx。
这是我的 android build.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"
}