On build, the compiler is throwing the following error:
Error:-
Severity Code Description Project File Line Suppression State Error Failed to create JavaTypeInfo for class: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/IAccessibilityStateChangeListenerImplementor due to System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\sHaRjAs\source\repos\FormsDatePickerFocusSample\FormsDatePickerFocusSample\FormsDatePickerFocusSample.Android\obj\Debug\90\android\src\mono\android\support\v4\view\accessibility\AccessibilityManagerCompat_AccessibilityStateChangeListenerImplementor.java'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at Xamarin.Android.Tools.Files.CopyIfStreamChanged(Stream stream, String destination) at Xamarin.Android.Tasks.Generator.CreateJavaSources(TaskLoggingHelper log, IEnumerable`1 javaTypes, String outputPath, String applicationJavaClass, String androidSdkPlatform, Boolean useSharedRuntime, Boolean generateOnCreateOverrides, Boolean hasExportReference)
XAML Code:-
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FormsDatePickerFocusSample"
x:Class="FormsDatePickerFocusSample.MainPage">
<StackLayout VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
BackgroundColor="White">
<Button x:Name="MyButton"
Text="Show DatePicker"
Clicked="OnMyButtonClicked"/>
<DatePicker x:Name="MyDatePicker"
IsVisible="False"/>
</StackLayout>
</ContentPage>
c#:-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace FormsDatePickerFocusSample
{
// Learn more about making custom code visible in the Xamarin.Forms
previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnMyButtonClicked(object sender, EventArgs e)
{
Device.BeginInvokeOnMainThread(() =>
{
if (MyDatePicker.IsFocused)
MyDatePicker.Unfocus();
MyDatePicker.Focus();
});
}
}
}