Getting byte[] or ByteBuffer[] from native Java

Hello,

I have a native Android plugin that has a method that does something and returns ByteBuffer.
I could change it to possibly return byte.

My problem is that I can’t seem to call that method from Unity…
I have triad to to this in the following way:

classInstance.Call<AndroidJavaObject>("methodName", 0);

or

classInstance.Call<byte[]>("methodName", 0);

The Java method looks something like:

public static byte[] methodName(int index){
    byte[] b = w/e
    return b;
}

I have triad making the method static or not static.
In all cases, I get the following error:

AndroidJavaException: java.lang.NoSuchMethodError: no static method with name=‘methodName’ signature=‘(I)Ljava/lang/Object;’ in class Ljava.lang.Object;

Any ideas as how I can this this to work? (getting the ByteBuffer is preferred but getting byte is also ok)

Thanks!

It’s a static method, so NoSuchMethodError makes sense, you’re trying to call instance method “methodName”.

Remove the ‘static’ modifier if you can, otherwise try using AndroidJavaClass and CallStatic:

AndroidJavaClass myClass = new AndroidJavaClass("com.myPackage.myClass");
byte[] result = myClass.CallStatic("methodName", 0);