android - 执行 org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException 时发生故障(无错误消息)

标签 android kotlin android-room kotlin-coroutines

Android工作室给出了错误:

Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
   > java.lang.reflect.InvocationTargetException (no error message)
我想在我的项目中添加 Kotlin Coroutines 并将其与 Room 数据库一起使用。但是在添加了所有库后,我得到了这个错误。这是来自编译器的所有信息。
我已经确定,这是因为注释 @Database。如果我删除了此注释,则不会出现错误,但 Room 也无法正常工作。
我的毕业文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
//apply plugin: 'androidx.navigation.safeargs'

kotlin {
    experimental {
        coroutines 'enable'
    }
}

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.bestcred.coursetthree"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        //vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    // Enables data binding.
    buildFeatures {
        dataBinding true
    }
}

dependencies {


    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // Support libraries
    implementation "androidx.appcompat:appcompat:1.2.0"
    implementation 'com.google.android.material:material:1.2.0'
    implementation "androidx.fragment:fragment:1.2.5"
    implementation "androidx.constraintlayout:constraintlayout:2.0.0"

    // Android KTX
    implementation 'androidx.core:core-ktx:1.3.1'

    // Room and Lifecycle dependencies
    implementation "androidx.room:room-runtime:$room_version"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    kapt "android.arch.persistence.room:compiler:$room_version"

    // Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:$room_version"

    // Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"

}

kotlin_version = "1.4.0"
room_version = "2.2.5"
coroutine_version = '1.3.9'
我更新了 Room 版本并添加了 Kotlin Coroutines。什么问题? enter image description here

最佳答案

Android Studio 的 UI 只是隐藏了错误......
发生错误时,它会在 ListView 中突出显示该项目,并在终端 View 中显示无用的消息。
unhelpful error message appears when erroneous item is selected
要找到真正的错误,请在 ListView 中选择根项,以便 Android Studio 在终端 View 中显示整个构建输出,然后滚动查找错误。
helpful error message appars when you select the root item from the list view on the left

关于android - 执行 org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException 时发生故障(无错误消息),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63649694/

相关文章:

javafx - 如何防止表格隐藏TornadoFX

java - Android - 如何解析 JSONObject 和 JSONArrays

android - 无法解析以下类的父类(super class)型

spring - Spring Boot运行错误bootRun工作正常,但应用程序运行不正常

android - 房间数据库无法预填充数据并且未创建数据库文件

java - 如何使用 viewModel 中的观察者方法解决 "anonymous class derived from observer"错误

java - 无法创建 com.example.architectureexample.NoteViewModel 类的实例

android - 当用户单击列表中的按钮时如何在展开列表中展开列表

php - 如何从本地数据库(mysql)获取上传的图像到android?

java - Json格式错误,已经获取数组时再请求数组