Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add v8 support #111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions android/src/main/java/com/reactlibrary/ReactContextBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.soloader.SoLoader;
import com.facebook.v8.reactexecutor.V8ExecutorFactory;

import java.util.ArrayList;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -65,8 +66,19 @@ private JavaScriptExecutorFactory getJSExecutorFactory() {
SoLoader.loadLibrary("jscexecutor");
return new JSCExecutorFactory(appName, deviceName);
} catch (UnsatisfiedLinkError jscE) {
// Otherwise use Hermes
return new HermesExecutorFactory();
// Otherwise try using hermes
try {
// we try whether we can start the hermes js executor.
// If it fails with an UnsatisfiedLinkError we know
// that it is not available.
JavaScriptExecutor hermes = new HermesExecutorFactory().create();
// stop if we were successful
hermes.close();
return new HermesExecutorFactory();
} catch (UnsatisfiedLinkError|NoClassDefFoundError e) {
// try v8
return new V8ExecutorFactory();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"android/",
"ios/",
"js/",
"index.js"
"index.js",
"react-native.config.js"
],
"peerDependencies": {
"react-native": ">=0.50.0"
Expand Down