【发布时间】:2020-07-08 12:33:13
【问题描述】:
我有一些数据类,其中包括他自己作为列表。 Android studio 显示下一个错误:
ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1C:\..\EventType.java:14: error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.
private final java.util.List<...EventType> children = null;
Task :app:kaptDebugKotlin FAILED
^
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
数据类是
@Entity(tableName = "eventType")
data class EventType(
@PrimaryKey val id: Int,
val name: String,
val children: List<EventType>,
val minAge: Int = 0
)
编辑:谢谢,下一条评论很有用
You have to use teh Room data type converter , look stackoverflow.com/questions/53085704/room-typeconverter – eurosecom
【问题讨论】:
-
你必须使用房间数据类型转换器,看stackoverflow.com/questions/53085704/room-typeconverter
标签: android android-studio kotlin android-room androidx