当前位置:网站首页>Execution failed for task 'encountered using room': app:kaptdebugkotlin‘
Execution failed for task 'encountered using room': app:kaptdebugkotlin‘
2022-07-21 11:48:00 【Bert. King】
Narrow path , Leave one step to let people go ;
When the taste is strong , Cut three points and invite people to taste .
1. Step on thunder
Project use Room database , You need to add a new operation method, and then make the corresponding Dao Some changes have been made , It turns out like this :
Execution failed for task ':app:kaptReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
Nima oh ,no error message It looks spicy and dazzling , Brilliant …
2. Demining
StackOverflow The plan This time, I really can't count on it .
Chairman Mao taught us : Do it yourself , Have ample food and clothing . Then roll up your sleeves and work hard …
In general , encounter build Errors in the process , Our correct posture is like this .
- open Android Studio On the right side of the Gradle;
- Find build, Conduct build And so on ;
As shown in the figure below :
Double click here build after , The details come out , It is extremely convenient to help us locate the problem .
error : Not sure how to convert a Cursor to this method’s return type (void).
3. summary
According to the above error location , It's easy to solve the problem …
The reason for the error :
SELECT The query needs to have a return value . Default return Cursor.
The document is described as follows :
For SELECT queries, Room will infer the result contents from the method’s return type and generate the code that will automatically convert the query result into the method’s return type. For single result queries, the return type can be any data object (also known as POJOs). For queries that return multiple values, you can use List or Array. In addition to these, any query may return Cursor or any query result can be wrapped in a LiveData.
INSERT queries can return void or long. If it is a long, the value is the SQLite rowid of the row inserted by this query. Note that queries which insert multiple rows cannot return more than one rowid, so avoid such statements if returning long.
UPDATE or DELETE queries can return void or int. If it is an int, the value is the number of rows affected by this query.
Just to summarize :
- SELECT Inquire about : Any query can return Cursor perhaps LiveData Results after packaging .
- Single result query : Return the data object directly (POJOs)
- Multiple result queries : have access to List perhaps Array
- INSERT Inquire about : No return value (void) perhaps long( Line number rowid)
- UPDATE and DELETE Inquire about : No return value (void) perhaps int( Rows affected )
Detailed document address :Query
4. Room Related knowledge
1. Room Persistence Library
2. Use Room Save data to local database
3. Room API file
Consider taking time , Write it specifically Room
边栏推荐
- Wechat applet 23 plays music page
- "Fundamentals of program design" Chapter 10 function and program structure 6-8 recursion for reverse order number (20 points)
- unity texturestreaming
- 高数 | 【概念剖析】一元、二元微分,连续、可微、可偏导、偏导连续的超强通俗解析!
- HTB-Lame
- Wechat applet 20 improve video page ①
- 2021-9-22
- SSM整合注解映射和XML映射两种方式
- Antd Table + Tooltip 时Tooltip无法跟随单元格移动——getPopupContainer改变Tooltip浮层渲染父节点
- lotus-bench 1.17.0-rc3 Benchmarks
猜你喜欢
随机推荐
When antd Table + tooltip, the tooltip cannot move with the cell -- getpopupcontainer changes the tooltip floating layer rendering parent node
WPS前骨干历时10年打造新型软件,Excel用户:我为此改用WPS
Why is kubernetes a new application server
HTB-Bashed
《程序设计基础》 第十章 函数与程序结构 6-13 分治法求解金块问题 (20 分)
2021-09-16
山东大学、北邮、哈工大| Multimodal Dialog Systems with Dual Knowledge-enhanced Generative Pretrained Language Model(具有双重知识增强生成预训练语言模型的多模态对话系统)
编程赛-土豆田
助力AI产业落地,云知声展示全栈AI硬核技术
使用Room所遇到的 Execution failed for task ‘:app:kaptDebugKotlin‘
微信小程序 25 npm模块和PubSubJS实现页面通讯
Wechat applet 05 obtains basic user information
解道4-编程术1
Django查询出MySQL数据库的QuerySet 对象数据 转化成 json 字符串
"Fundamentals of program design" Chapter 10 function and program structure 6-6 recursive implementation sequential output integer (15 points)
DEBUG:Generate Bitstream失败
Disassembly of Huawei P30 Pro: compact structure, fine workmanship, exposure of core device suppliers!
Try to understand the essence of low code platform design from another angle
Shandong University, Beijing post, Harbin Institute of technology | multimodal dialog systems with dual knowledge enhanced generic trained language model
AIX mount NFS write inefficient solution