-
Notifications
You must be signed in to change notification settings - Fork 15
Add Android support #4
base: master
Are you sure you want to change the base?
Conversation
@tomduncalf refactor this & I’ll merge! Unless you prefer it left open. |
553a2ad
to
3dd4926
Compare
3dd4926
to
6f16c01
Compare
Done! Happy to merge it, but if you know anyone at Facebook who you could point in this direction to take a look at the exception I get in debug (and more generally if this is the right approach), that would be great :) |
|
||
@Override | ||
public void onReactContextInitialized(ReactContext context) { | ||
install(context.getJavaScriptContextHolder().get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internally also, this is where we install the JSI Modules.
If you are just exposing native methods, why not use React Native's TurboModuleManager - whose intenet is pretty much that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I wasn’t sure if TurboModules were ready to use or not! If they are it would be awesome to see an example of how to use them :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@axemclion could you please provide an example on how to use turbo modules in that case?
extern "C" | ||
{ | ||
JNIEXPORT void JNICALL | ||
Java_com_testmodule_MainActivity_install(JNIEnv* env, jobject thiz, jlong runtimePtr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In React native's case, you can use fbjni, which helps out with types i nJNI. Check out TurboModuleManager.cpp.
This code is similar to what we do there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is where I copied it from, I think – or are you suggesting using TurboModuleManager
directly?
@@ -36,8 +36,8 @@ | |||
2D16E6881FA4F8E400B85C8A /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D16E6891FA4F8E400B85C8A /* libReact.a */; }; | |||
2DCD954D1E0B4F2C00145EB5 /* TestModuleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* TestModuleTests.m */; }; | |||
2DF0FFEE2056DD460020B375 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; }; | |||
68E307DC2262762A00B130DF /* TestBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 68E307DA2262762A00B130DF /* TestBinding.cpp */; }; | |||
68E3080C2262781F00B130DF /* Test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 68E3080A2262781F00B130DF /* Test.cpp */; }; | |||
736B0C4F228AB89E000DC273 /* TestBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 736B0C4B228AB89D000DC273 /* TestBinding.cpp */; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also curious why the xcode project changed here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file moved: ios/TestBinding.cpp → c++/TestBinding.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, sorry I missed your message @axemclion!
Build failed with an exception
replace BUILD SUCCESSFUL |
This PR adds Android support, by refactoring the existing module code into a shared location and adding the necessary CMake config, JNI method and Java call to install the JSI native module on Android.
There is one issue, which I have no idea how to solve: in debug mode, there are a load of exceptions of type
SIGUSR1
which happen. If you just click "continue", the app still works, but it's a bit weird - perhaps someone involved in React and JSI could take a look at this PR and give their feedback?