簡體   English   中英

Android Studio 4.1 Canary 6 issue with kapt plugin (e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState)

[英]Android Studio 4.1 Canary 6 issue with kapt plugin (e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState)

我使用 Android Studio 4.1 Canary 6 版本,我嘗試使用apply plugin: 'kotlin-kapt'插件,然后在構建項目期間出現此錯誤。

e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;

這里項目級別 gradle

buildscript {
    ext.kotlin_version = "1.3.70"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0-alpha06'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

這是應用程序級別 gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'kotlin-kapt'
}
......
......
dependencies {

 //room database
    implementation 'androidx.room:room-runtime:2.2.5'
    implementation "androidx.room:room-ktx:2.2.5"
    kapt 'androidx.room:room-compiler:2.2.5'
}

我在使用 Compose 時遇到了同樣的問題,因為與 kotlinCompilerVersion 相比,我為 stdlib 和 gradle 插件使用了不同的版本:

// WRONG: Different Kotlin versions
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20"

android {
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion '1.4.10'
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.20"
}

根據我的情況,如果您不使用 Compose,我的猜測是存在使用不同 Kotlin 版本的依賴項(甚至是子模塊)並且編譯器崩潰。 這似乎與 Kotlin 的 IR 后端有關。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM