xiconify icon indicating copy to clipboard operation
xiconify copied to clipboard

IconDrawable JNI native constructor missing

Open adamhalesworth opened this issue 5 years ago • 0 comments

When attempting to dispose of the IconDrawable framework peer efficiently using the following code:

using (var icon = new IconDrawable(itemView.Context, MaterialIcons.md_chevron_right.ToString()).WithColor(Color.White))
{
    chevron.SetImageDrawable(icon);
}               

The following exception is thrown:

Unhandled Exception:

System.NotSupportedException: Unable to activate instance of type JoanZapata.XamarinIconify.IconDrawable from native handle 0xbfa004fc (key_handle 0xbb6afc0).

06-25 12:13:36.122 V/Mono    (20566): [0x86d7e970] try unpark worker
06-25 12:13:36.122 V/Mono    (20566): [0x86d7e970] try unpark worker, success? yes
06-25 12:13:36.122 V/Mono    (20566): [0x86d7e970] request worker, unparked
06-25 12:13:36.122 V/Mono    (20566): [0x859fe970] worker unparking, timeout? no interrupted? no
06-25 12:13:36.122 V/Mono    (20566): [0x859fe970] worker parking
06-25 12:13:36.127 E/mono-rt (20566): [ERROR] FATAL UNHANDLED EXCEPTION: System.NotSupportedException: Unable to activate instance of type JoanZapata.XamarinIconify.IconDrawable from native handle 0xbfa004fc (key_handle 0xbb6afc0). ---> System.MissingMethodException: No constructor found for JoanZapata.XamarinIconify.IconDrawable::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
06-25 12:13:36.127 E/mono-rt (20566):    --- End of inner exception stack trace ---
06-25 12:13:36.127 E/mono-rt (20566):   at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00036] in /Users/builder/data/lanes/6102/ba9da7a7/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:303 
06-25 12:13:36.127 E/mono-rt (20566):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00116] in /Users/builder/data/lanes/6102/ba9da7a7/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:281 
06-25 12:13:36.127 E/mono-rt (20566):    --- End of inner exception stack trace ---
06-25 12:13:36.127 E/mono-rt (20566):   at (wrapper dynamic-method) System.Object.36(intptr,intptr)
06-25 12:13:36.127 E/mono-rt (20566):   at (wrapper native-to-managed) System.Object.36(intptr,intptr)

It looks like the IconDrawable class needs another constructor:

public IconDrawable(IntPtr javaRef, JniHandleOwnership transfer) : base(javaRef, transfer)
{
    Init();
}

adamhalesworth avatar Jun 25 '19 11:06 adamhalesworth