I'm trying Migrate my Xamarin Android app with AndroidX. After Migrate this error is coming.
using AndroidX.Fragment.App;
using Xamarin.Forms.Platform.Android;
using AndroidX.AppCompat.App;
private void ShowDatePicker()
{
if (_monthYearPickerDialog == null)
{
_monthYearPickerDialog = new MonthYearPickerDialog();
_monthYearPickerDialog.OnDateTimeChanged = OnDateTimeChanged;
_monthYearPickerDialog.OnClosed = OnClosed;
}
_monthYearPickerDialog.Date = Element.Date;
var appcompatActivity = CrossCurrentActivity.Current.Activity as AppCompatActivity;
var mFragManager = appcompatActivity?.SupportFragmentManager;
if (mFragManager != null)
{
_monthYearPickerDialog.Show(mFragManager, nameof(MonthYearPickerDialog));
}
}
Any help is appreciated. Thanks!
CodePudding user response:
You cannot mix types from Support.V4 namespace with AndroidX namespace. So it is super weird that you are defining this in the top of the file:
using Fragment = Android.Support.V4.App.Fragment;
using SupportV4 = Android.Support.V4.App;
You should use Fragment from AndroidX.Fragment
instead.
Stop mixing up things and your errors will go away.