1
votes

I want to implement a custom entry in xamarin, followed some youtube tutorials step by step and it works on them but mine crashes when launching it via a live player.

Here is the code in the shared project

using Xamarin.Forms;

namespace QuickTest.CustomControls
{
    public class PlainEntry : Entry
    {
    }
}

And here is the android specific version

using Android.Content;
using QuickTest.CustomControls;
using QuickTest.Droid.CustomAndroidControls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(PlainEntry), typeof(PlainEntryAndroid))]
namespace QuickTest.Droid.CustomAndroidControls
{
    public class PlainEntryAndroid : EntryRenderer
    {
        public PlainEntryAndroid() : base(null) { }

        public PlainEntryAndroid(Context context) : base(context) { }
    }
}

Its a basic implementation i commented out the OnElementChanged function just so i could get it to run first, is there something am doing wrong, any help would be highly appreciated because i have already wasted enough time on this, thanks.

Btw I have also tried it without either of the constructors and it failed.

1
I tested your code but it works fine on my side, could you please post more detailed codes? or maybe share a basic demo that can reproduce the problem through online repo - Eren Shen
This frustratrated me so much i decided to write platform specific ui, so gave up mvvm pattern, and btw, it didn't give out any error, just xamarin player was crashing @YorkShen-MSFT - lulliezy

1 Answers

1
votes

Xamarin crashes on Android when creating custom renderer. it didn't give out any error, just xamarin player was crashing

Please refer to the documentation: Limitations of Xamarin Live Player

For Xamarin.Forms:

  • Custom Renderers are not supported.
  • Effects are not supported.
  • Custom Controls with Custom Bindable Properties are not supported.
  • Embedded resources are not supported (ie. embedding images or other resources in a PCL).
  • Third party MVVM frameworks are not supported (ie. Prism, Mvvm Cross, Mvvm Light, etc.).

That's why the issue happened. So, it is suggested that deploy your project to an android emulator or a real device.