I am trying to build a plugin that I can call through a unity project on ML2.
The plugin builds on Android Studio for x86_64 release. However on ML2, the library is unreachable. It seems to me I don't have the right config to build for ML2 on Android studio.
I have followed the "Android Studio Workflow" guide on the ML2 developer documentation but I can't seem to figure out the issue.
How to enable a build variant for ML2 on android studio?
Tried calling a function in the android x86_64 plugin to add 2 number (passed in as 2 arguments) and return the result. Its only returns the first operand as the result. Seemed like a calling convention issue to me. Tried with calling conventions Cdecl, StdCall, ThisCall, FastCall through Unity. All had the same result. The android plugin package (.so) is configured as x86_64 executable in Unity.
Here is the snapshot of my current config:
ML2 OS version: Build: B3E.221020.13-R.039
MLSDK version: SDK Version 29
Host OS: Windows 10
Common Packages
C API Samples: 1.1.0-dev2
ML C SDK: 1.1.0-dev2
ML C SDK CMake Support: 1.0.6.0
ML OS: 1.1.0-dev2 (Secure)
*** ML2 Addon was added to SDK Update sites ***
*** Command line options in Settings->Build,Exec, Deployment->Compiler was set to :
-Proot_path=C:\Users\robot\MagicLeap\mlsdk\v1.1.0-dev2
@robot is the issue that the APIs are not being recognized or that you are unable to build the library file? Have you been able to build the Magic Leap Native Samples?
The APIs are recognized. I can call a function in the plugin and it returns a result. Just not the correct one. Seems like a calling convention issue. Like the parameters being passed and getting manged/truncated or something..
eg. calling an API from unity test_add(15,25) returns 15 from the plugin on the device.
the function signature in Unity (C#) is :
[DllImport(libname, CallingConvention = CallingConvention.Cdecl)]
private static extern int test_add(int handle, int opa, int opb);
The code in the plugin on android studio (C++) is :
extern "C"
{
int test_add(int handle, int opa, int opb);
}