- Home /
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!
You should use AndroidJavaClass if you are calling a static
@ShadyProductions I prefer it not to be static.... I changed it in the hopes that it will make it work. I had the same error when it was not static.
Answer by gnp89 · Jun 07, 2017 at 05:18 PM
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);