【问题标题】:Unable to use Kotlin-kapt with kotlin/native无法将 Kotlin-kapt 与 kotlin/native 一起使用
【发布时间】:2018-08-07 13:04:42
【问题描述】:

编译器在普通 kotlin/native 模块中使用时无法识别任何 kapt 依赖项

apply plugin: 'konan'
apply plugin: 'kotlin-platform-common'
apply plugin: 'kotlin-kapt'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib"
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
compile "com.jakewharton:butterknife:8.8.1"
//kapt "com.jakewharton:butterknife-compiler:8.8.1"
}

konan.targets = ['iphone', 'iphone_sim']
def frameworkName = 'XplatformAnalytics'
konanArtifacts {
framework(frameworkName)
}

【问题讨论】:

  • 这在与 'kotlin-platform-android' 一起使用时不起作用
  • 你是否在 gradle 文件中添加这一行:apply plugin: 'com.android.application'
  • 那也没用。

标签: android kotlin kapt kotlin-native


【解决方案1】:

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

【讨论】:

    【解决方案2】:
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'kotlin-kapt'
    
    
    buildscript {
        ext.kotlin_version = '1.2.10'
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.2'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多