Android UnsatisfiedLink错误:

时间:2015-12-03 16:00:13

标签: android dependencies unsatisfiedlinkerror couchbase-lite

我正在开发一个我添加的Android应用程序     依赖到build.gradle文件,如下所示。   但我收到错误,因为我添加了UnsatisfiedLink Error.Dependency 和     logcat如下:

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile files('libs/couchbase-lite-android-1.1.0.jar')


12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime: FATAL EXCEPTION: main
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime: java.lang.ExceptionInInitializerError
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.lite.android.AndroidSQLiteStorageEngine.open(AndroidSQLiteStorageEngine.java:57)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.lite.Database.open(Database.java:977)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.lite.Manager.getDatabase(Manager.java:243)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.examples.couchdbthird.MainActivity.helloCBL(MainActivity.java:50)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.examples.couchdbthird.MainActivity.onCreate(MainActivity.java:31)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5104)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5041)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:  Caused by: java.lang.UnsatisfiedLinkError: Couldn't load com_couchbase_touchdb_TDCollateJSON from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.couchbase.examples.couchdbthird-1.apk,libraryPath=/data/app-lib/com.couchbase.examples.couchdbthird-1]: findLibrary returned null
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at java.lang.Runtime.loadLibrary(Runtime.java:365)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at java.lang.System.loadLibrary(System.java:535)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.touchdb.TDCollateJSON.<clinit>(TDCollateJSON.java:36)
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.lite.android.AndroidSQLiteStorageEngine.open(AndroidSQLiteStorageEngine.java:57) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.lite.Database.open(Database.java:977) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.lite.Manager.getDatabase(Manager.java:243) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.examples.couchdbthird.MainActivity.helloCBL(MainActivity.java:50) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.couchbase.examples.couchdbthird.MainActivity.onCreate(MainActivity.java:31) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5104) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5041) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
12-03 09:12:22.520 25190-25190/com.couchbase.examples.couchdbthird E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 

2 个答案:

答案 0 :(得分:0)

您还需要添加此行

compile fileTree(include: ['*.jar'], dir: 'libs')

答案 1 :(得分:0)

由于你使用的是jar文件,你必须注意嵌套的依赖:

检查pom file您可以看到此库使用:

 <dependencies>
    <dependency>
      <groupId>com.couchbase.lite</groupId>
      <artifactId>couchbase-lite-java-core</artifactId>
      <version>1.1.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

此库有lot of dependencies:

 <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.5.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.github.oxo42</groupId>
      <artifactId>stateless4j</artifactId>
      <version>2.4.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.5.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.5.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

我建议您避开jar文件并使用此依赖项:

dependencies {
  compile 'com.couchbase.lite:couchbase-lite-android:1.1.0'
}