Java.lang.IllegalStateException: 后端内部错误:代码生成期间出现异常。

8
我正在尝试新的Jetpack Compose,但是当我切换到时,出现以下错误:java.lang.IllegalStateException: Backend Internal error: Exception during code generation。使用annotationProcessor可以正常工作,但我想在这个项目中使用kapt。希望能得到任何关于此问题的帮助。
我知道很多问题都可能导致以上错误,但我认为这个问题与和有关。
下面是我的.gradle文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "me.jerryhanks.pinchme"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

//        javaCompileOptions {
//            annotationProcessorOptions {
//                arguments = [
//                        "room.schemaLocation":"$projectDir/schemas".toString(),
//                        "room.incremental":"true",
//                        "room.expandProjection":"true"]
//            }
//        }
    }

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

    buildFeatures {
        compose true
    }

// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'

    /**Compose*/
    implementation 'androidx.ui:ui-layout:0.1.0-dev02'
    implementation 'androidx.ui:ui-material:0.1.0-dev02'
    implementation 'androidx.ui:ui-tooling:0.1.0-dev02'

    /**Corountine*/
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.coroutine"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutine"
//    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$versions.coroutine"

    /**Room*/
    implementation "androidx.room:room-runtime:$versions.room"
    kapt "androidx.room:room-compiler:$versions.room"

    /**Test*/
    testImplementation 'junit:junit:4.12'
    testImplementation "androidx.room:room-testing:$versions.room"

    /**Android Test*/
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

请发布您的Gradle文件。 - Manoj Perumarath
我已经添加了我的 .gradle 文件。 - Jerry Okafor
1
我写了一个答案,但因为“没有回答问题”而被删除 ¯\(ツ)/¯:由于此错误 https://youtrack.jetbrains.com/issue/KT-34583,Compose和Room目前不兼容。 - Tim Trueman
2个回答

0

这似乎是一个 bug,团队仍在努力解决。

Compose仍处于实验阶段,不应在生产应用程序中使用。此外,Compose需要启用Kotlin编译器的新/实验IR(Intermediate Representation)后端,因此您可能会遇到与新后端相关的语言错误。

Compose需要IR后端(带有Google扩展功能)。


0

这个问题似乎已经在较新版本的Compose中得到了解决。请尝试使用1.0.0beta08版本。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接