Error using ExportAttribute with array parameter

edited January 28 in Xamarin.Android

When I'm using ExportAttribute on a managed method with array parameter like this:

    public static int A(int[] b) { ... }

I'll get:

    NotSupportedException: Only primitive types and IJavaObject is supported in array type in callback method parameter or return value

But "int" is a primitive type.

I've found this link on GitHub:
But the problem isn't solved.


  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    As atsushieno point out, avoid depending on any code that requires [Export] by writing managed code that overrides existing Java methods which would result in a working Java callable wrappers though. For any native (C) functions P/Invoke just works.

    I will sync with you if any more PG’s feedback comes out.

  • BIZIBIZI Member

    I know I can use P/Invoke, but [Export] is the better(only) choice especially when I can't change the C code or the native code uses too many JNI features to change easily.

    The official explanation in the forum:
    makes an example which uses ExportAttribute with array parameters, so I think this problem is unexpected and should be solved.

    I don't want to see this bug ignored(seems like) again and hope it will be fixed as soon as possible= =.

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    You could post a comment on the github: #1259, Xamarin PG will give it a higher priority if a lot people hope this issue could be fixed. :)

Sign In or Register to comment.