android - java.lang.IllegalStateException:后端内部错误:代码生成期间出现异常
问题描述
我正在尝试新的 Jetpack compose,但是当我切换到 时kapt
,我收到此错误:java.lang.IllegalStateException: Backend Internal error: Exception during code generation
.
它与 annotationProcessor 一起工作得很好,但我想在这个项目中使用 kapt。我将不胜感激。
我知道很多问题都可能导致上述错误,但我认为这个问题是特有的,jetpack
并且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'
}
解决方案
这似乎是团队仍在努力解决的错误。
Compose 仍处于试验阶段,不应在生产应用程序中使用。此外,Compose 需要为 Kotlin 编译器启用新的/实验性的 IR(中间表示)后端,因此您可能会遇到与新后端相关的语言错误。
Compose 确实需要 IR 后端(带有 Google 扩展)。
推荐阅读
- opencv - 我的 Google Colab PRO 在训练期间断开连接 - 如何保存和恢复我的训练
- r - 如何使用 R 中的 acf 和 pacf 图确定 AR/MA 项的顺序
- python - 如何从 Python 中网页内的链接获取数据?
- deep-learning - Pytorch 中的正确验证损失?
- java - 我无法获得 JSON 数据“预期为 BEGIN_ARRAY,但在第 1 行第 2 列路径 $ 处为 BEGIN_OBJECT”
- python - 嵌套 numpy.where 函数
- javascript - event "transitionend" is calling a function twice in React?
- javascript - Mongoose 排序,.sort() 查询输出不符合预期
- python - 如何让一个数字增长 1 n 倍
- java - 用户定义的异常