6

我正在尝试在 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());

4

3 回答 3

18

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

SQLiteDatabase.loadLibs(Context context)

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

请在此处查看说明

于 2013-06-10T13:24:14.327 回答
1
No implementation found for native Linfo/guardianproject/database/sqlcipher/SQLiteDatabase;.dbopen (Ljava/lang/String;I)V

您的代码似乎与您正在运行的版本不兼容。确保它们兼容。

于 2012-04-30T13:30:17.107 回答
0

http://www.coderanch.com/t/79145/Websphere/Native-lib-already-loaded-another

这个“不满意的链接”错误可能是由于已经加载了一个类,但是运行时类加载器层次结构中的错误类加载器。

疯狂的猜测是 Sqllite 包在那里并且在 Classpath 中,但是在运行测试的场景中,错误的加载器实例加载了 DB 包。

于 2012-04-30T13:52:39.903 回答