当运行一个查询从房间数据库返回一些数据时,我在API23物理设备上得到了这个崩溃。
LOGCAT
E/AndroidRuntime: FATAL EXCEPTION: arch_disk_io_2
java.lang.RuntimeException: Exception while computing database live data.
at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:92)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: column '`allOrNothing`' does not exist
at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:333)
at androidx.room.util.CursorUtil.getColumnIndexOrThrow(CursorUtil.java:108)
at com.example.persistence.dao.DaoPieChart_Impl$2.call(DaoPieChart_Impl.java:169)
at com.example.persistence.dao.DaoPieChart_Impl$2.call(DaoPieChart_Impl.java:164)
at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:90)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818) 我已经看过了表和模型,看不到问题。列名明显存在。
表格
@Entity (tableName = "tableDistortedThinking")
public class TableDistortedThinking {
@PrimaryKey(autoGenerate = true)
private long pkDistortedThinking;
@ColumnInfo(name = "reframingId")
private long fkReframingId;
@ColumnInfo(name = "userId")
private long fkUserId;
@ColumnInfo(name = "allOrNothing")
private Integer allOrNothing;模型
public class ModelPieChart {
private long userId;
private String twistedName;
private Integer allOrNothing;
private Date workoutDate;
private int DistortedThinkingCount;查询
@Query("SELECT TableDistortedThinking.allOrNothing, COUNT(TableDistortedThinking.allOrNothing) AS DistortedThinkingCount, TableDistortedThinking.workoutDate, TableDistortedThinking.userId, TableDistortedNames.distortedName AS twistedName " +
"FROM TableDistortedThinking " +
"JOIN TableDistortedNames ON TableDistortedThinking.allOrNothing = TableDistortedNames.pkDistortedNameId " +
"WHERE TableDistortedThinking.workoutDate >= (1000 * strftime('%s', datetime('now', :dateRange)))" +
"AND TableDistortedThinking.userId = :userId " +
"GROUP BY TableDistortedNames.distortedName " +**他们的查询非常长,并且由UNION连接,但只有这一节是真正相关的。任何导致这次崩溃的帮助根用户都会非常感谢。
发布于 2020-08-13 21:59:10
此故障是由运行API 25或更低版本的设备上发生的Room错误引起的。在房间版本2.3.0-alpha02中修复。有关更多详细信息,请参阅description in the Google IssueTracker。
https://stackoverflow.com/questions/63380871
复制相似问题