У меня возникли некоторые проблемы с использованием комнаты из компонентов архитектуры Android.Вся структура работала без каких-либо проблем, пока я не попытался реализовать @ForeignKey
в моей таблице.Если я пытаюсь вставить новый предмет, появляется надгробная плита.
Объект задачи
@SuppressLint("ParcelCreator")
@Parcelize
@Entity(
foreignKeys = [(ForeignKey(
entity = Category::class,
parentColumns = ["id"],
childColumns = ["category_id"],
onDelete = ForeignKey.CASCADE
))],
indices = [(Index(value = ["category_id"]))]
)
data class Task(
@ColumnInfo(name = "completed_flag") var completed: Boolean = false,
@ColumnInfo(name = "task_description") var description: String?,
@ColumnInfo(name = "category_id") var categoryId: Long = 0
) : Parcelable {
@IgnoredOnParcel
@ColumnInfo(name = "id")
@PrimaryKey(autoGenerate = true)
var id: Long = 0
}
Категория объекта
@Parcelize
@Entity
data class Category(
@ColumnInfo(name = "name") var name: String?,
@ColumnInfo(name = "color") var color: String?
) : Parcelable {
@IgnoredOnParcel
@ColumnInfo(name = "id")
@PrimaryKey(autoGenerate = true)
var id: Long = 0
}
Контракт задачи
fun addTask(task: Task): Observable<Unit>? =
Observable.fromCallable { taskDao.insertTask(task) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Когда я удаляю аннотацию @ForeignKey
и рассматриваю внешнее поле как простое поле, оно работает.
То, что я пробовал:
- Заменить Rx
Flowable
на LiveData
- Заменить на
.observeOn(Schedulers.io())
- Заменить на
Completable.fromAction()
- Удалить
Parcelize
, поскольку он находится в эксперименте - Удалить
@ForeignKey
индексное поле - Объявление внешнего поля вне конструктора
Обратный след Tombstone
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #00 pc 00000000 <unknown>
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #01 pc 00025cdd /system/lib/libsqlite.so
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #02 pc 00025011 /system/lib/libsqlite.so
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #03 pc 0000eb95 /system/lib/libsqlite.so
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #04 pc 0002d60d /system/lib/libsqlite.so
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #05 pc 0003b409 /system/lib/libsqlite.so
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #06 pc 00010931 /system/lib/libsqlite.so (sqlite3_step+536)
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #07 pc 0007f175 /system/lib/libandroid_runtime.so
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #08 pc 018a0a33 /system/framework/arm/boot-framework.oat (offset 0x15f4000) (android.database.sqlite.SQLiteConnection.nativeExecute+102)
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #09 pc 018a34b9 /system/framework/arm/boot-framework.oat (offset 0x15f4000) (android.database.sqlite.SQLiteConnection.execute+260)
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #10 pc 018b3741 /system/framework/arm/boot-framework.oat (offset 0x15f4000) (android.database.sqlite.SQLiteSession.endTransactionUnchecked+364)
2018-06-02 21:52:29.940 27583-27583/? A/DEBUG: #11 pc 018b3ee5 /system/framework/arm/boot-framework.oat (offset 0x15f4000) (android.database.sqlite.SQLiteSession.endTransaction+144)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #12 pc 018ac61d /system/framework/arm/boot-framework.oat (offset 0x15f4000) (android.database.sqlite.SQLiteDatabase.endTransaction+72)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #13 pc 000a91c1 /system/lib/libart.so (art_quick_invoke_stub_internal+64)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #14 pc 004031e9 /system/lib/libart.so (art_quick_invoke_stub+232)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #15 pc 000b0455 /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+136)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #16 pc 001ec389 /system/lib/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+200)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #17 pc 001e6939 /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+492)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #18 pc 003fd663 /system/lib/libart.so (MterpInvokeVirtualQuick+322)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #19 pc 0009fd94 /system/lib/libart.so (ExecuteMterpImpl+29972)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #20 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #21 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #22 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #23 pc 003fb92b /system/lib/libart.so (MterpInvokeInterface+826)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #24 pc 0009c214 /system/lib/libart.so (ExecuteMterpImpl+14740)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #25 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #26 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #27 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #28 pc 003fd663 /system/lib/libart.so (MterpInvokeVirtualQuick+322)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #29 pc 0009fd94 /system/lib/libart.so (ExecuteMterpImpl+29972)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #30 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #31 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #32 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #33 pc 003fb92b /system/lib/libart.so (MterpInvokeInterface+826)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #34 pc 0009c214 /system/lib/libart.so (ExecuteMterpImpl+14740)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #35 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #36 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #37 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #38 pc 003fd663 /system/lib/libart.so (MterpInvokeVirtualQuick+322)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #39 pc 0009fd94 /system/lib/libart.so (ExecuteMterpImpl+29972)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #40 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #41 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #42 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #43 pc 003fb92b /system/lib/libart.so (MterpInvokeInterface+826)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #44 pc 0009c214 /system/lib/libart.so (ExecuteMterpImpl+14740)
2018-06-02 21:52:29.941 27583-27583/? A/DEBUG: #45 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #46 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #47 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #48 pc 003fd663 /system/lib/libart.so (MterpInvokeVirtualQuick+322)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #49 pc 0009fd94 /system/lib/libart.so (ExecuteMterpImpl+29972)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #50 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #51 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #52 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #53 pc 003fb92b /system/lib/libart.so (MterpInvokeInterface+826)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #54 pc 0009c214 /system/lib/libart.so (ExecuteMterpImpl+14740)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #55 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #56 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #57 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #58 pc 003fb92b /system/lib/libart.so (MterpInvokeInterface+826)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #59 pc 0009c214 /system/lib/libart.so (ExecuteMterpImpl+14740)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #60 pc 001ca783 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #61 pc 001cf2eb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #62 pc 001e691f /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
2018-06-02 21:52:29.942 27583-27583/? A/DEBUG: #63 pc 003fb92b /system/lib/libart.so (MterpInvokeInterface+826)
У вас есть идеи?