gpt4 book ai didi

android - java.lang.UnsatisfiedLinkError : dbopen 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:57:08 25 4
gpt4 key购买 nike

我正在尝试在 android 应用程序的代码块上编写 Android 测试用例。该代码块将与数据库(sqlcipher 库函数)交互,特别是 dbopen() 函数。运行应用程序时,它工作正常。当我们试图为该代码块(涉及数据库交互)执行测试用例时。它给出以下错误:java.lang.UnsatisfiedLinkError: dbopen

任何人都可以对此进行调查并提出建议。

测试用例不能有权调用正在调用 sqlcipher 库函数的函数。 是否需要任何权限,或是否有针对此类测试用例的任何特定程序?

完整的错误日志:

            04-30 12:08:33.997: I/TestRunner(2169): started: teststateMachine(com.americanlogistics.mdd.rhapsody.view.test.SigninViewsateMachineTest)
04-30 12:08:34.147: W/dalvikvm(2169): No implementation found for native Linfo/guardianproject/database/sqlcipher/SQLiteDatabase;.dbopen (Ljava/lang/String;I)V
04-30 12:08:34.164: I/TestRunner(2169): failed: teststateMachine(com.americanlogistics.mdd.rhapsody.view.test.SigninViewsateMachineTest)
04-30 12:08:34.164: I/TestRunner(2169): ----- begin exception -----
04-30 12:08:34.184: I/TestRunner(2169): java.lang.UnsatisfiedLinkError: dbopen
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.dbopen(Native Method)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.<init>(SQLiteDatabase.java:1870)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:863)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:897)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.database.SendQueueDBAdapter.open(SendQueueDBAdapter.java:45)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.database.SendQueueDBAdapter.databaseHelperInstance(SendQueueDBAdapter.java:38)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.common.ApplicationController.startDatabase(ApplicationController.java:530)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.view.test.SigninViewsateMachineTest.teststateMachine(SigninViewsateMachineTest.java:61)
04-30 12:08:34.184: I/TestRunner(2169): at java.lang.reflect.Method.invokeNative(Native Method)
04-30 12:08:34.184: I/TestRunner(2169): at java.lang.reflect.Method.invoke(Method.java:507)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestCase.runTest(TestCase.java:154)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestCase.runBare(TestCase.java:127)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestResult$1.protect(TestResult.java:106)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestResult.runProtected(TestResult.java:124)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestResult.run(TestResult.java:109)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestCase.run(TestCase.java:118)
04-30 12:08:34.184: I/TestRunner(2169): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
04-30 12:08:34.184: I/TestRunner(2169): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
04-30 12:08:34.184: I/TestRunner(2169): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
04-30 12:08:34.184: I/TestRunner(2169): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
04-30 12:08:34.184: I/TestRunner(2169): ----- end exception -----

代码:

测试用例中的下面一行是间接调用sqlcipher库函数。

ApplicationController.getInstance().startDatabase(this.getContext().getApplicationContext());

最佳答案

我在为 Android 集成 SQLCipher 时遇到了同样的错误。我的解决方案是调用

SQLiteDatabase.loadLibs(Context context)

按照建议,在使用数据库本身之前。在应用程序的派生类中调用它的好地方。

Please see the instructions here

关于android - java.lang.UnsatisfiedLinkError : dbopen 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10384386/

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