All my searches pointed me to this repository.
I'm trying to add in some C code that I've generated using MATLAB Coder into my {N} app. I've looked at https://github.com/NativeScript/android-runtime/issues/291 and it gave me a bit of sense as to how to load an .so file that I should generate using Gradle. That's all fine, but it seems that the example in the sample-native-module uses C++ code (whereas I am suing C code), which is a bit different from various examples I've seen for adding C code into Android apps:
https://youtu.be/DWnadVCwMJw?t=2306
https://www.youtube.com/watch?v=G0vL7-_xuDM
Notably, I understood that I need to implement a method NSMain which would be called by {N} when I run var myModule = require('./libMyModule.so');.
The structure of NSMain is different than it seems in the other examples I viewed.
Since I was unable to find adequate examples or guides for this matter, I was hoping to get some example or clarification on how to implement NSMain and call on the exports object from V8 in order to successfully add my C functions for use in {N}.
Thanks in advance.
Hi @NirLevanon,
If you want to generate C code that can be used with NativeScript, first you'll need to build a .so library.
make or any other build system to generate that shared library. You can look at our example here of how you can build such a library with make..so file you can simply put it in with the rest of your javascript code in <app_name>/app/ folder and require it from javascript.@NirLevanon I managed to import this app(https://github.com/CrazyOrr/FFmpegRecorder) into aar library and call it from my {N} Application. It uses javacpp.
Here is my implementation. currently working.
some errors happened during the development
(https://github.com/CrazyOrr/FFmpegRecorder/issues/5#issuecomment-254101072)
(https://github.com/NativeScript/android-runtime/issues/584)
Most helpful comment
@NirLevanon I managed to import this app(https://github.com/CrazyOrr/FFmpegRecorder) into aar library and call it from my {N} Application. It uses javacpp.
Here is my implementation. currently working.
some errors happened during the development
(https://github.com/CrazyOrr/FFmpegRecorder/issues/5#issuecomment-254101072)
(https://github.com/NativeScript/android-runtime/issues/584)