2016-12-08 6 views
1

こんにちは、データベース暗号化用にsqlcipherをアクティブにしたアクティブなAndroidを使用しています。それは正常に動作しています。暗号化されたデータベースを使用してアプリケーションを作成することができます。今私はテストケースのためにロボ選択を使用しています。そして、それは私にリンクエラーのエラーを与えています。私は自分のgradleバージョンを更新しました。ですから、私は.soファイルを含んでいません。robolectricを使用したsqlcipherのUnsatisfiedLinkError

java.lang.UnsatisfiedLinkError: no sqlcipher in java.library.path 

    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864) 
    at java.lang.Runtime.loadLibrary0(Runtime.java:870) 
    at java.lang.System.loadLibrary(System.java:1122) 
    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:196) 
    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:189) 
    at com.example.android.testing.unittesting.BasicSample.SampleApplication.onCreate(SampleApplication.java:20) 
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:141) 
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:234) 
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:171) 
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:47) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:137) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) 
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) 
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 


java.util.ServiceConfigurationError: org.robolectric.internal.ShadowProvider: Provider org.robolectric.shadows.multidex.Shadows not a subtype 

    at java.util.ServiceLoader.fail(ServiceLoader.java:239) 
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185) 
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376) 
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) 
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480) 
    at org.robolectric.internal.bytecode.InstrumentationConfiguration$Builder.build(InstrumentationConfiguration.java:151) 
    at org.robolectric.RobolectricTestRunner.createClassLoaderConfig(RobolectricTestRunner.java:115) 
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:169) 
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:47) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:137) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) 
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) 
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 

https://groups.google.com/forum/#!topic/sqlcipher/i_Gw-7d8DpU robolecticはケースをシミュレートするためにJVMを使用しAccounding:その代わりに、私は次のエラーを取得しています

ndk { 
     abiFilters "armeabi", "armeabi-v7a", "x86", "mips" 
    } 

を使用しています。 .soファイルはサポートされません。これらのケースを解消するには、デバイスまたはエミュレータで行う必要があります。この問題を解決するには?助けが要る。

答えて

1

いくつかのこと:あなたが.soのライブラリに依存しているクラスをテストする場合

  1. (のはそれNativeClassを呼びましょう) - それは動作しません。
  2. NativeClassに依存するクラスをテストする場合は、NativeClassを直接使用する代わりにinterfaceを使用し、そのインターフェイスをモックします。
0

あなたのAndroidプロジェクトに正しくsqlcipherをインポートする必要があります。

1)フォルダを作成しjniLibsプロジェクトの下 \アプリ\ SRC \主な...それは、これらのProject\app\src\main\jniLibs\

2)今、正しいフォルダの下sqlcipher.soファイルを置く(1見えるように持っています):

Project\app\src\main\jniLibs\armeabi\sqlcipher.so 
Project\app\src\main\jniLibs\armeabi-v7a\sqlcipher.so 
Project\app\src\main\jniLibs\mips\sqlcipher.so 
Project\app\src\main\jniLibs\x86\sqlcipher.so 

3)ここで、静的インポートを、このライブラリを使用するクラス内の任意の場所に追加します。

static { 
     try { 
      //Libraryname without .so!! 
      System.loadLibrary("sqlcipher"); 
     } 
     catch(UnsatisfiedLinkError ex) 
     { 
      //Not found 
     } 
    } 

プロジェクトをコンパイルします。たぶん、プロジェクトもきれいです。 私はこれが助けてくれることを願っています!もっと助けが必要なら教えてください!

EDIT: たぶん

\ armeabi \ sqlcipher.so libsの下の.soファイルを追加しよう
関連する問題