DLToolkit.Forms.Controls
DLToolkit.Forms.Controls copied to clipboard
TagEntry in xf3.2 crash
in xamarin forms 3.2, when touch keybord blank space , the app crash .
and throw errors:
System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.EntryRenderer from native handle 0x7fef11dcb4 (key_handle 0x64dfe53).
This error is xamarin.forms ??
Thanks .
The very bad error. This can happen for many reasons
https://stackoverflow.com/questions/10593022/monodroid-error-when-calling-constructor-of-custom-view-twodscrollview/10603714#10603714
BTW after upgrading the Xamarin.Forms to the latest version (Version >=3.2), my app was crashing with this and similar following exception,
System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.FormsEditText from native handle 0xbff9dd3c (key_handle 0x6ff142a). occurred
And I managed to fix this by making the changes to the TagEntryRenderer as below,
[assembly: ExportRenderer(typeof(TagEntry), typeof(TagEntryRenderer))]
namespace MyProject.Android.Renderers
{
public class TagEntryRenderer : EntryRenderer
{
public static void Init()
{
#pragma warning disable 0219
var dummy = new TagEntryRenderer(MainActivity.Context);
#pragma warning restore 0219
}
public TagEntryRenderer(Context context) : base(context)
{
}
public TagEntryRenderer(Context context, IAttributeSet attrs) : base(context)
{
}
public TagEntryRenderer(Context context, IAttributeSet attrs, int defStyle) : base(context)
{
}
public TagEntryRenderer(IntPtr a, JniHandleOwnership b) : base(MainActivity.Context)
{
}
//Please see comment below
protected override FormsEditText CreateNativeControl()
{
return new FormsEditTextExtended(MainActivity.Context);
}
}
/*
* In order to fix the exception below, we're using this workaround.
* This workaround was not required in XF3.1 but on latest XF versions it causes issues
* System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.AnAndroid.FormsEditText from native handle 0xbff9dd3c (key_handle 0x6ff142a). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.AnAndroid.FormsEditText::.ctor(System.IntPtr, AnAndroid.Runtime.JniHandleOwnership)
*/
public class FormsEditTextExtended : FormsEditText
{
public FormsEditTextExtended(Context context) : base(context)
{
}
public FormsEditTextExtended(IntPtr a, JniHandleOwnership b) : base(MainActivity.Context)
{
}
}
}