Fallback to System.loadLibrary if SoLoader has not been initialized

Summary: To make the library easier to get started with we don't want to force people to use SoLoader. If SoLoader is not initialized we will fall back to the standard System.loadLibrary() method.

Reviewed By: lucasr

Differential Revision: D3661990

fbshipit-source-id: f2003577aa3d2f89ec579b6f889fdfb684110b60
This commit is contained in:
Emil Sjolander
2016-08-04 08:20:06 -07:00
committed by Facebook Github Bot 9
parent f5caf93c6e
commit b32d384337

View File

@@ -20,7 +20,13 @@ import com.facebook.soloader.SoLoader;
public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
static {
SoLoader.loadLibrary("csslayout");
try {
SoLoader.loadLibrary("csslayout");
} catch (Exception ignored) {
// The user probably didn't call SoLoader.init(). Fall back to System.loadLibrary() instead.
System.out.println("Falling back to System.loadLibrary()");
System.loadLibrary("csslayout");
}
}
private CSSNodeJNI mParent;