gpt4 book ai didi

android - 未使用房间的项目中房间的运行时异常

转载 作者:行者123 更新时间:2023-11-29 23:45:45 25 4
gpt4 key购买 nike

我突然开始在应用程序启动时收到此运行时异常,而根本没有空间作为我的依赖项。

07-20 19:48:37.703 18737-18771/mypackage.x E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
Process: mypackage, PID: 18737
java.lang.IllegalStateException: A migration from 3 to 2 was required but not found. Please provide the necessary Migration path via RoomDatabase.Builder.addMigration(Migration ...) or allow for destructive migrations via one of the RoomDatabase.Builder.fallbackToDestructiveMigration* methods.
at android.arch.persistence.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:97)
at android.arch.persistence.room.RoomOpenHelper.onDowngrade(RoomOpenHelper.java:109)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onDowngrade(FrameworkSQLiteOpenHelper.java:144)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:396)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54)
at android.arch.persistence.room.RoomDatabase.compileStatement(RoomDatabase.java:244)
at android.arch.persistence.room.SharedSQLiteStatement.createNewStatement(SharedSQLiteStatement.java:65)
at android.arch.persistence.room.SharedSQLiteStatement.getStmt(SharedSQLiteStatement.java:72)
at android.arch.persistence.room.SharedSQLiteStatement.acquire(SharedSQLiteStatement.java:87)
at androidx.work.impl.model.WorkSpecDao_Impl.resetScheduledState(WorkSpecDao_Impl.java:337)
at androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork(WorkManagerImpl.java:514)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)

以下是我从 Android arch 获得的一些依赖项:

implementation "androidx.core:core-ktx:$ktx_version"
implementation "android.arch.paging:runtime:$paging_runtime"
implementation("android.arch.lifecycle:extensions:$android_arc_version") {
force = true
}

implementation "android.arch.navigation:navigation-fragment-ktx:$navigation_version"
// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui-ktx:$navigation_version"
implementation "android.arch.work:work-runtime-ktx:$work_version"

知道是什么原因造成的吗?

最佳答案

事实证明,android.arch.work:work 依赖于 room 库,而我使用的是 work 库的 1.0.0-alpha03 版本。我想排除依赖关系,但我注意到工作组件有可用更新,在尝试之后,它解决了问题。所以升级你的工作库来解决这个问题(此时更新的版本是1.0.0-alpha04)

关于android - 未使用房间的项目中房间的运行时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51452576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com