I am currently creating an Android library for use in a react native project. I need to emit a map to javascript, so I'm using react native's WriteableMap class. Unfortunately, the class loads the reactnativejni SO in a static block, which leads to an UnsatisfiedLinkError during unit tests. I'm using JUnit and Mockito to test.
My code:
@Override
public void onSomething() {
WritableMap params = Arguments.createMap();
//fill map
sendEvent("onChange", params);
}
The error:
java.lang.UnsatisfiedLinkError: no reactnativejni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:172)
at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:23)
at com.facebook.react.bridge.Arguments.createMap(Arguments.java:29)
at me.MyClass.onSomething(myClass.java:23)
I started using the Arguments.createMap()
method after seeing a comment about stubbing WriteableMap for unit tests, but it's static and I would prefer to not have to stub a static method.
Is there some way to get rid of this error when running unit tests?