Execution failed for task ‘:app:kaptDebugKotlin‘. > A failure occurred while executing org.jetbrains

本文介绍了如何处理Kotlin编译任务执行失败的问题,特别是关于Kapt和Room库的使用。检查内容包括确认kotlin-kapt插件已启用,Dao接口编写正确,以及考虑升级Kotlin版本以解决兼容性问题。对于出现的'java.lang.reflect.InvocationTargetException'错误,建议检查Dao接口中的SQL查询语句,确保表名和字段名准确无误。

报错代码

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-kapt加入到你的grade里面吗

apply plugin: 'kotlin-kapt'

dependencies {

def room_version = "2.2.6"

    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
}

然后80%是你的Dao接口写错了去好好检查一下

package com.yuge.passwords.db.dao

import androidx.room.*
import com.yuge.passwords.db.entity.Account

//Database access object
@Dao
public interface AccountDao{

    @Insert
    public fun insertAccount(account: Account)

    @Delete
    public fun deleteAccount(account: Account)

    @Update
    public fun updateAccount(account: Account)

    @Query("delete from table_account")
    public fun deleteAllAccounts()

    @Query("select * from table_account order by accountId")
    public fun selectAllOrderById():List<Account>

    @Query("select * from account order by searchNum desc")//account 表名错了
    public fun selectAllOrderBySNum():List<Account>

}

再有可能是版本问题 将你的kotlin升级版本 老版本可能是不兼容

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值