Hey guys,
after the pain of setting up Robolectric with Android Studio I am facing another problem now:
I get an UnsatisfiedLinkError when using Robolectric on an activity, which uses Couchbase Lite. Couchbase Lite, apparently, relies on native libraries to perform.
So I read a lot about this (at least what I could find). I tried the following things:
Using gradlew -Djava.library.path=bla/bla/bla test (with an absolute path to the directory and an relative path beginning from project root).
I also added the following to my build gradle:
tasks.withType(Test) {
systemProperty "java.library.path", "src/main/jniLibs"
}
(and with an absolute path)
Because all this ends up in UnsatisfiedLinkErrors I tried loading the library with the following command:
System.load("/path/to/library/armeabi-v7a/com_couchbase_touchdb_TDCollateJSON.so");
The library is found. But the following Error occurs:
java.lang.UnsatisfiedLinkError: /path/to/lib/armeabi-v7a/com_couchbase_touchdb_TDCollateJSON.so: no suitable image found. Did find: /path/to/lib/armeabi-v7a/com_couchbase_touchdb_TDCollateJSON.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00
To sum it up: I assume I am facing two problems here.
The first one is: How to set the correct library path for gradlew?
And the second one, which is more painful:
Since Robolectric does not use the Emulator or an Android device to run the tests, it runs on my Mac. And the *.so library is not a native Mac library, this is why it says: "unknown filetype" in the error above. This leads me to the question? Does anybody know how to avoid loading the library? Or does anybody know if there are Mac libraries of Couchbase, which I could use?
I appreciate your effort and am looking forward to your answers.
Cheers,
Jan