Reputation: 370
When running a query to return some data from the room database I am getting this crash on API 23 physical device.
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)
I have went through the table and model and cannot see the problem. The column name clearly exists.
TABLE
@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;
MODEL
public class ModelPieChart {
private long userId;
private String twistedName;
private Integer allOrNothing;
private Date workoutDate;
private int DistortedThinkingCount;
QUERY
@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 " +
**They query is very long and is connected by UNION ALL but only this section is really relevant. Any help root causing this crash would be greatly appreciated.
Upvotes: 1
Views: 1221
Reputation: 38319
This failure is caused by a Room bug that occurs on devices running API 25 or lower. It is fixed in room version 2.3.0-alpha02. See the description in the Google IssueTracker for more details.
Upvotes: 5