Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 由于找不到列,房间数据库崩溃_Android_Sqlite_Android Sqlite_Android Room - Fatal编程技术网

Android 由于找不到列,房间数据库崩溃

Android 由于找不到列,房间数据库崩溃,android,sqlite,android-sqlite,android-room,Android,Sqlite,Android Sqlite,Android Room,当运行一个查询以从房间数据库返回一些数据时,我在API 23物理设备上得到了这个崩溃 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

当运行一个查询以从房间数据库返回一些数据时,我在API 23物理设备上得到了这个崩溃

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) 
我已经检查了表格和模型,看不出问题所在。列名显然存在

桌子

模型

质疑

**他们的查询很长,由联合连接,但只有这一部分是真正相关的。
任何导致此崩溃的帮助都将不胜感激。

此故障是由运行API 25或更低版本的设备上发生的房间错误引起的。它固定在房间版本2.3.0-alpha02中。有关更多详细信息,请参阅。

此故障是由运行API 25或更低版本的设备上发生的房间错误引起的。它固定在房间版本2.3.0-alpha02中。有关更多详细信息,请参阅。

如果您使用的Android Studio版本具有,请使用它检查您的数据库。您的文件室架构似乎与实际数据库不一致。我不确定这是怎么可能的,因为我增加了版本号,它会破坏一切并重新开始。您可以通过查看文件室为DAO生成的
\Impl
文件找到一些线索。您可以在项目中的
app
下找到它,标签为
java(generated)
。我对错误消息中关于列不存在的
allOrNothing
的倒勾感到困惑。Room在生成的SQL声明(请参见生成的架构)中添加了反勾号以引用表名和列名,但我希望它们不会进入查询的
\u Impl
代码中。这似乎是一个Room错误。请参阅:如果您使用的Android Studio版本具有,请使用它检查您的数据库。您的文件室架构似乎与实际数据库不一致。我不确定这是怎么可能的,因为我增加了版本号,它会破坏一切并重新开始。您可以通过查看文件室为DAO生成的
\Impl
文件找到一些线索。您可以在项目中的
app
下找到它,标签为
java(generated)
。我对错误消息中关于列不存在的
allOrNothing
的倒勾感到困惑。Room在生成的SQL声明(请参见生成的架构)中添加了反勾号以引用表名和列名,但我希望它们不会进入查询的
\u Impl
代码中。这似乎是一个Room错误。见:
@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 " +