【发布时间】:2020-01-19 11:59:24
【问题描述】:
在构建时,编译器抛出以下错误:
错误:-
严重性代码描述项目文件行抑制状态 错误无法为类创建 JavaTypeInfo: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/IAccessibilityStateChangeListenerImplementor 由于 System.IO.DirectoryNotFoundException: 找不到一部分 路径 'C:\Users\sHaRjAs\source\repos\FormsDatePickerFocusSample\FormsDatePickerFocusSample\FormsDatePickerFocusSample.Android\obj\Debug\90\android\src\mono\android\support\v4\view\accessibility\AccessibilityManagerCompat_AccessibilityStateChangeListenerImplementor.java'。 在 System.IO.__Error.WinIOError(Int32 错误代码,字符串可能全路径) 在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess 访问、Int32 权限、布尔用户权限、FileShare 共享、Int32 bufferSize,FileOptions 选项,SECURITY_ATTRIBUTES secAttrs,字符串 msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
在 System.IO.FileStream..ctor(字符串路径,FileMode 模式,FileAccess 访问,文件共享共享,Int32 bufferSize)在 Xamarin.Android.Tools.Files.CopyIfStreamChanged(流流,字符串 目的地)在 Xamarin.Android.Tasks.Generator.CreateJavaSources(TaskLoggingHelper 日志,IEnumerable`1 javaTypes,字符串输出路径,字符串 applicationJavaClass, String androidSdkPlatform, Boolean useSharedRuntime, Boolean generateOnCreateOverrides, Boolean hasExportReference)
XAML 代码:-
<?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();
});
}
}
}
【问题讨论】:
-
我使用相同的代码进行测试。没有错误。您可以尝试清理并重建此项目或删除此项目的 bin 和 obj 文件数据重试。如果您仍然收到此编译器错误,快速的方法是创建一个新项目以使用代码进行测试。
-
@WendyZang 它不起作用(Soln 未更改)
-
我在GitHub上上传了我的测试项目,你可以下载测试。 github.com/WendyZang/Test如果还有错误,能否分享更多代码供我测试?
-
有什么更新吗?你的问题解决了吗?
标签: c# xamarin xamarin.forms