Hi, I have generated a .so shared library using ko...
# kotlin-native
m
Hi, I have generated a .so shared library using kotlin/native. I am using this .so shared library in my different android project. I am able to load the library but I am not able to call the functions, I think the methods name have to be with JNI underscore or something, is there a way to get details like method names of the .so shared library inside android project? (after we do System.loadLibrary(".so library name"))
n
You have to use the CName annotation to your K/N methods:
@CName(Java_com_my_package_myMethodName)
m
and how do I call the method from my android app? suppose my method name is My kotlin native code
@CName(Java_com_my_package_manan)
fun hello(){ } Now inside my android app main java class : class { init { System.loadLibrary("native.so") } //what should I do here to call function hello from native.so? }
btw @natario1 Thanks for the response, please do let me know about the above query.
n
You declare an external method. Check out https://jonnyzzz.com/blog/2019/12/15/jni-kotlin/
m
Thanks a lot, it worked! It has one problem though, I have imported C code of tensorflow in my kotlin/native project, I am not able to use it's methods in my android project. Do you have any idea why?