gpt4 book ai didi

Room 2.5.2 runtime crash - NoSuchFieldError: No instance field mDelegate of type SQLiteStatement(Room 2.5.2运行时崩溃- NoSuchFieldError:No instance field mDelegate of type SQLiteStatement)

转载 作者:bug小助手 更新时间:2023-10-28 11:40:11 28 4
gpt4 key购买 nike



I'm trying to update the Room database library on an Android app I'm developing from version 2.4.3 to 2.5.2, these are the Room dependencies in my gradle.build file

我正在尝试更新我正在从2.4.3版开发到2.5.2版的Android应用程序上的Room数据库,这些是我的gradle.build文件中的Room依赖项


dependencies {
val room_version = "2.5.2"
implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$room_version")
kapt("androidx.room:room-compiler:$room_version")

}

The app compiles and builds successfully, but unfortunately at runtime, when a query is used, Room crashes with NoSuchFieldError error.

该应用程序成功编译和构建,但不幸的是,在运行时,当使用查询时,Room崩溃并出现NoSuchFieldError错误。


FATAL EXCEPTION: Thread-29
Process: my.app, PID: 29657
java.lang.NoSuchFieldError: No instance field mDelegate of type Landroid/database/sqlite/SQLiteStatement; in class Landroidx/sqlite/db/framework/FrameworkSQLiteStatement; or its superclasses (declaration of 'androidx.sqlite.db.framework.FrameworkSQLiteStatement' appears in /data/app/~~8vd8qCDSVAv==/my.app/base.apk)
at androidx.sqlite.db.framework.FrameworkSQLiteStatement.executeInsert(Unknown Source:0)
at androidx.room.EntityInsertionAdapter.insertAndReturnId(EntityInsertionAdapter.kt:102)

After taking a quick look at the source code, it appears that my code at the stacktrace line

在快速查看源代码之后,我的代码似乎位于堆栈跟踪行


at androidx.sqlite.db.framework.FrameworkSQLiteStatement.executeInsert(Unknown Source:0)

points to this class

指向此类


package androidx.sqlite.db.framework

import android.database.sqlite.SQLiteStatement
import androidx.sqlite.db.SupportSQLiteStatement

/**
* Delegates all calls to a [SQLiteStatement].
*
* @constructor Creates a wrapper around a framework [SQLiteStatement].
*
* @param delegate The SQLiteStatement to delegate calls to.
*/
internal class FrameworkSQLiteStatement(
private val delegate: SQLiteStatement
) : FrameworkSQLiteProgram(
delegate
), SupportSQLiteStatement {
override fun execute() {
delegate.execute()
}

override fun executeUpdateDelete(): Int {
return delegate.executeUpdateDelete()
}

override fun executeInsert(): Long {
return delegate.executeInsert()
}

override fun simpleQueryForLong(): Long {
return delegate.simpleQueryForLong()
}

override fun simpleQueryForString(): String? {
return delegate.simpleQueryForString()
}
}

Which can be found here
https://androidx.tech/artifacts/sqlite/sqlite-framework/2.3.0-source/androidx/sqlite/db/framework/FrameworkSQLiteStatement.kt.html

可在此处找到https://androidx.tech/artifacts/sqlite/sqlite-framework/2.3.0-source/androidx/sqlite/db/framework/FrameworkSQLiteStatement.kt.html


That's the source code for the androidx.sqlite:sqlite-framework dependency version 2.3.0.

这是androidx.sqlite:sqlite-framework依赖关系版本2.3.0的源代码。


And based on the stacktrace logs, it seem that Room is instead pointing to an older version based on the "mDelegate" field.

根据堆栈跟踪日志,Room似乎指向基于“mDelegate”字段的旧版本。


https://androidx.tech/artifacts/sqlite/sqlite-framework/2.0.1-source/androidx/sqlite/db/framework/FrameworkSQLiteStatement.java.html

Https://androidx.tech/artifacts/sqlite/sqlite-framework/2.0.1-source/androidx/sqlite/db/framework/FrameworkSQLiteStatement.java.html


That's androidx.sqlite:sqlite-framework version 2.0.1, which has a field defined as "mDelegate".

这就是androidx.sqlite:sqlite-framework version2.0.1,它有一个定义为“mDelegate”的字段。


It looks like (correct me if I'm wrong) that the Room library at runtime is looking for classes from an old version of sqlite, or that the Room library in its entirety along with its transitive dependencies on sqlite are all running older versions at runtime, despite what I actually have at compile time.

看起来(如果我错了,请纠正我),Room库在运行时正在寻找来自旧版本的SQLite的类,或者Room库及其对SQLite的传递依赖项在运行时都在运行旧版本,尽管我在编译时实际拥有的是什么。


Tried looking everywhere for what might be causing this. Nothing came up.

我试着到处寻找可能导致这一切的原因。什么都没想出来。


Things I've observed:

我观察到的一些事情:



  • I'm currently on Room version 2.4.3, and the issue started appearing exactly on version 2.5.0-beta01. I slowly incremented version numbers from the android website until I found out exactly where it started appearing. I tested every version between 2.5.0-beta01 and 2.5.2 and they're all causing this runtime crash.

    我目前使用的是Room版本2.4.3,而这个问题开始出现在版本2.5.0-beta01上。我慢慢地增加了Android网站上的版本号,直到我找到它开始出现的确切位置。我测试了2.5.0-beta01和2.5.2之间的每个版本,它们都导致了这次运行时崩溃。



  • The issue exists in different phones from different OEMs, it isn't related to a specific device.

    该问题存在于来自不同OEM的不同手机中,与特定设备无关。



  • I ran the gradle dependencies tree task and didn't find any transitive room/sqlite dependencies being used by any libraries!

    我运行了Gradle依赖项树任务,没有发现任何库正在使用任何可传递的空间/SQLite依赖项!




Things I tried:

我尝试过的事情:



  • I tried updating all the other Android dependencies, at least most of them (My project has several dozens of dependencies). I tried updating all the Androidx and Kotlin dependencies and tried commenting out most of the third party dependencies.

    我尝试更新所有其他Android依赖项,至少大部分(我的项目有几十个依赖项)。我尝试更新所有的androidx和Kotlin依赖项,并尝试注释掉大多数第三方依赖项。



  • I tried switching from kapt() to ksp() and later annotationProcessor() for the room compiler dependency. Didn't matter.

    我尝试将房间编译器依赖项从kapt()切换到ksp(),然后再切换到nottationProcessor()。无关紧要。



  • I tried forcing Room and sqlite versions through strictly {} and resolutionStrategy{} blocks in my gradle.build file.

    我尝试通过我的gradle.build文件中严格的{}和resoltionStrategy{}块强制使用Room和Sqlite版本。


      configurations.all {
    resolutionStrategy {
    force("androidx.room:room-runtime:2.5.2")
    force("androidx.room:room-ktx:2.5.2")
    force("androidx.room:room-compiler:2.5.2")
    force("androidx.sqlite:sqlite-framework:2.3.1")
    }
    }


    dependencies {
    implementation("androidx.room:room-runtime") {
    version {
    strictly("2.5.2")
    }
    }
    // etc for the rest of the room and sqlite dependencies
    }



Due to this issue, I'm now forced to be stuck on an old version of Room, potentially indefinitely, and libraries like Workmanager 2.8.1 that implicitly/transitively depends on Room versions older than 2.5.0 cannot be updated, since I'm required to update Room with it as well.

由于这个问题,我现在被迫使用旧版本的Room,可能是无限期的,而像WorkManager 2.8.1这样隐含/传递地依赖于早于2.5.0的Room版本的库无法更新,因为我也需要用它更新Room。


更多回答

I have absolutely the same issue and have no idea what to do

我完全有同样的问题,不知道该怎么办

优秀答案推荐

It looks like that the cause of this crash is old version of sentry library.
I updated sentry library in build.gradle of app to last one and all works.

看起来这个崩溃的原因是旧版本的哨兵库。我更新了应用程序的build.gradle中的哨兵库到最后一个和所有作品。


plugins {
...
id "io.sentry.android.gradle" version "3.12.0"

}

}


更多回答

Thanks! I'm also using sentry, forgot about this one since it's version is specified in the plugins gradle block and not the dependencies block. I'll try updating it.

谢谢!我还使用了Sentry,忘记了这一点,因为它的版本是在plugins Gradle块中指定的,而不是在依赖项块中指定的。我会试着更新一下。

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