Open lzunsec opened 3 years ago
To do this, just define JNI_OnLoad in your shared library and use the JavaVM object passed in there... Make sure to call System.loadLibrary to load your shared object in Java before anything. Either you do it by extending the Application class or in a static block inside of your Activity. Either way, load the library before Dart does so that the JNI_OnLoad gets called and your other libraries get initialized
@lzunsec did you ever find a solution to this?
Sorry but this is a highly specific question about the VM, I triged glitter but couldn't get help as this is very specific.
Some libraries, like JUCE (juce.com), requires this to be called on startup:
This calls C++ code with Java
Context
.What if I want to load Juce with FFI directly through Flutter on Android? I want to use FFI so I have direct access to the C functions.
However, it's unclear how shared library loading on Dart VM occurs on Android. How would I get this
Context
from the Dart VM?I bet Dart won't call
JNI_Onload
so I can register some java function that gets the context:JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
Is it even possible to access
JavaVM
though a library loaded from Dart VM?