1

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();
        });
    }
    }
}
4
  • I test with the same code. There is no error. You could try to clean and rebuild this project or delete the bin and obj file data of this project to try again. If you still get this complier error, the quick way is to create a new project to test with the code. Commented Sep 19, 2019 at 6:03
  • @WendyZang it's not working (Soln not changed) Commented Sep 19, 2019 at 13:28
  • I uploaded my test project on GitHub, you could download to test. github.com/WendyZang/Test If you still have errors, could you share more code for me to test? Commented Sep 20, 2019 at 6:35
  • Any update? Have you solved your problem? Commented Sep 25, 2019 at 7:03

1 Answer 1

3

Have had a similar error just now. I found that it is connected to my VS solution name beeing kind of descriptive and long

WebApp_ReportGenerator_Framework_Dink_Oxy

If I created another project with something shorter for a solution and project name (TestProj), the android project built with no errors.

@sHaRjAs:
I guess the path to the java files in question (see error description) is too long because your project name is too long. There are also other solutions than project renaming to solve this problem: Solutions here and here oficial.

PS. If in xamarin forms one is using the

<PropertyGroup> <IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath> </PropertyGroup>

solution, note that "MyApp" folder in upper path is the folder containing all your forms projects : Android,UWP, IOs and standard API projects. This is not clear in the docmentation, I think.

For example if you put in the IntermediateOutputPath property the path to your android project, the Visual Studio locks and needs to be "endTasked".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.