0

运行环境

SQLDelight 版本:1.4.3
应用操作系统:Android

错误描述

我正在尝试在库级别创建 SQLDelight 作为 kotlin 多平台库并将其部署为 android 库...

然后,当我将它作为依赖项添加到我的 Android 应用程序中时(单独的项目,因为我想将其视为稍后使用我的库的客户端),我遇到了以下堆栈跟踪的运行时问题:

2020-12-01 10:02:40.827 3642-3642/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.socketdummy, PID: 3642
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.socketdummy-iBZCoVo2j0qCEXnpJ23JAg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.socketdummy-iBZCoVo2j0qCEXnpJ23JAg==/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libsqlitejdbc.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at org.sqlite.core.NativeDB.<clinit>(NativeDB.java:38)
        at org.sqlite.core.NativeDB.load(NativeDB.java:53)
        at org.sqlite.core.CoreConnection.open(CoreConnection.java:211)
        at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25)
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
        at org.sqlite.JDBC.createConnection(JDBC.java:114)
        at org.sqlite.JDBC.connect(JDBC.java:88)
        at java.sql.DriverManager.getConnection(DriverManager.java:580)
        at java.sql.DriverManager.getConnection(DriverManager.java:190)
        at com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver.<init>(JdbcSqliteDriver.kt:25)
        at com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver.<init>(JdbcSqliteDriver.kt:14)
        at bca.lib.data.local.driver.DatabaseDriverFactory.createDriver(DatabaseDriverFactory.kt:21)
        at bca.lib.data.local.driver.DatabaseDriverFactoryKt.getSQLDriver(DatabaseDriverFactory.kt:29)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$6.invoke(KodeinInjector.kt:22)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$6.invoke(Unknown Source:2)
        at org.kodein.di.bindings.Singleton$getFactory$1$1$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Reference$Local$Companion.invoke$kodein_di(references.kt:16)
        at org.kodein.di.bindings.Strong$Companion.make(references.kt:31)
        at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:96)
        at org.kodein.di.bindings.StandardScopeRegistry.getOrCreate(scopes.kt:64)
        at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:96)
        at org.kodein.di.internal.DIContainerImpl$factory$1.invoke(DIContainerImpl.kt:160)
        at org.kodein.di.DIContainer$provider$$inlined$toProvider$1.invoke(curry.kt:14)
        at org.kodein.di.internal.DirectDIBaseImpl.Instance(DirectDIImpl.kt:30)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$5.invoke(KodeinInjector.kt:25)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$5.invoke(Unknown Source:2)
        at org.kodein.di.bindings.Singleton$getFactory$1$1$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Reference$Local$Companion.invoke$kodein_di(references.kt:16)
        at org.kodein.di.bindings.Strong$Companion.make(references.kt:31)
        at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:96)
        at org.kodein.di.bindings.StandardScopeRegistry.getOrCreate(scopes.kt:64)
        at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:96)
        at org.kodein.di.internal.DIContainerImpl$factory$1.invoke(DIContainerImpl.kt:160)
        at org.kodein.di.DIContainer$provider$$inlined$toProvider$1.invoke(curry.kt:14)
        at org.kodein.di.internal.DirectDIBaseImpl.Instance(DirectDIImpl.kt:30)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$4.invoke(KodeinInjector.kt:25)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$4.invoke(Unknown Source:2)
        at org.kodein.di.bindings.Singleton$getFactory$1$1$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Reference$Local$Companion.invoke$kodein_di(references.kt:16)
2020-12-01 10:02:40.829 3642-3642/? E/AndroidRuntime:     at org.kodein.di.bindings.Strong$Companion.make(references.kt:31)
        at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:96)
        at org.kodein.di.bindings.StandardScopeRegistry.getOrCreate(scopes.kt:64)
        at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:127)
        at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:96)
        at org.kodein.di.internal.DIContainerImpl$factory$1.invoke(DIContainerImpl.kt:160)
        at org.kodein.di.DIContainer$provider$$inlined$toProvider$1.invoke(curry.kt:14)
        at org.kodein.di.internal.DirectDIBaseImpl.Instance(DirectDIImpl.kt:30)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$2.invoke(KodeinInjector.kt:25)
        at bca.lib.di.KodeinInjectorKt$kodeinInjector$1$2.invoke(Unknown Source:2)
        at org.kodein.di.bindings.Provider$getFactory$1.invoke(standardBindings.kt:86)
        at org.kodein.di.bindings.Provider$getFactory$1.invoke(standardBindings.kt:80)
        at org.kodein.di.internal.DIContainerImpl$factory$1.invoke(DIContainerImpl.kt:160)
        at org.kodein.di.DIContainer$provider$$inlined$toProvider$1.invoke(curry.kt:14)
        at org.kodein.di.internal.DirectDIBaseImpl.Instance(DirectDIImpl.kt:30)
        at bca.lib.ConnectionManager$connect$provisionUseCase$2.invoke(ConnectionManager.kt:28)
        at bca.lib.ConnectionManager$connect$provisionUseCase$2.invoke(ConnectionManager.kt:10)
        at org.kodein.di.DIAwareKt$newInstance$1.invoke(DIAware.kt:268)
        at org.kodein.di.DIAwareKt$newInstance$1.invoke(Unknown Source:4)
        at org.kodein.di.DIProperty$provideDelegate$1.invoke(properties.kt:46)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at bca.lib.ConnectionManager.connect(ConnectionManager.kt:16)
        at com.example.socketdummy.MainActivity.lambda$onCreate$0(MainActivity.java:31)
        at com.example.socketdummy.-$$Lambda$MainActivity$GO0OJj7ZT4UkfvPtudR0IznuTHw.onClick(Unknown Source:2)
        at android.view.View.performClick(View.java:7125)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:992)
        at android.view.View.performClickInternal(View.java:7102)
        at android.view.View.access$3500(View.java:801)
        at android.view.View$PerformClick.run(View.java:27336)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

它说没有找到“libsqlitejdbc.so”......,我犯错了吗?以及如何解决这个问题?

根据我了解的文档,我刚刚在我的 Android 应用程序中添加了以下依赖项:

implementation 'com.squareup.sqldelight:android-driver:1.4.3'

我需要在以下条件下解决此问题:

  1. SQLDelight定义在Library层(包括.sq,驱动实际定义),可以部署为android lib或iOS框架
  2. 它可以稍后在客户端应用程序中实现为依赖项(例如:Android / iOS)

谢谢

4

1 回答 1

2

不知何故,您已经包含了 jdbc 驱动程序。请参阅堆栈跟踪中与com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver. 我猜这可能是因为您打算让他们以这种方式在 JVM 中运行测试,或者您还使该库可用于服务器端并且配置设置不正确。查看 gradle 配置可能会有所帮助。

于 2020-12-01T12:49:06.437 回答