`Java.Lang.NoSuchMethodError` 使用导航抽屉时出现异常

`Java.Lang.NoSuchMethodError` exception while using Navigation Drawer

我正在尝试使用 Syncfusion SfNavigationDrawer 创建 navigation drawer,但我在 android 模拟器上遇到以下异常。

Java.Lang.NoSuchMethodError: no method with name='setClipToOutline' signature='(Z)V' in class Lcom/xamarin/forms/platform/android/FormsViewGroup;

这是我的代码:

public class MainPage : ContentPage
{       
    public MainPage()
    {
        SfNavigationDrawer nav = new SfNavigationDrawer();

        StackLayout mainStack = new StackLayout();
        mainStack.Opacity = 1;
        mainStack.Orientation = StackOrientation.Vertical;
        mainStack.HeightRequest = 500;
        mainStack.BackgroundColor = Color.White;

        ObservableCollection<String> list = new ObservableCollection<string>();
        list.Add("Home");


        ListView listView = new ListView();
        listView.WidthRequest = 200;
        listView.VerticalOptions = LayoutOptions.FillAndExpand;
        listView.ItemsSource = list;
        mainStack.Children.Add(listView);

        nav.DrawerContentView = mainStack;


        StackLayout headerLayout = new StackLayout();
        headerLayout.Orientation = StackOrientation.Vertical;

        Image image = new Image();
        image.Source = ImageSource.FromFile("user.png");
        headerLayout.Children.Add(image);

        Label header = new Label();
        headerLayout.Children.Add(header);
        nav.DrawerHeaderView = headerLayout;



        Button imageButton = new Button();
        imageButton.WidthRequest = 50;

        Label homeLabel = new Label();
        homeLabel.Text = "Home";
        homeLabel.FontSize = 15;
        homeLabel.TextColor = Color.White;
        homeLabel.HorizontalTextAlignment = TextAlignment.Center;
        homeLabel.VerticalTextAlignment = TextAlignment.Center;

        StackLayout headerFrame = new StackLayout();
        headerFrame.Orientation = StackOrientation.Horizontal;
        headerFrame.Children.Add(imageButton);
        headerFrame.Children.Add(homeLabel);

        Label mainLabel = new Label();
        mainLabel.Text = "Lorem...";

        StackLayout ContentFrame = new StackLayout();
        ContentFrame.Orientation = StackOrientation.Vertical;
        ContentFrame.BackgroundColor = Color.White;
        ContentFrame.Children.Add(headerFrame);
        ContentFrame.Children.Add(mainLabel);
        nav.ContentView = ContentFrame;

        nav.Position = Position.Left;
        nav.Transition = Transition.SlideOnTop;

        this.Content = nav;

    }
}

我正在使用 Xamarin.Forms 2.3.0.49Syncfusion ES 14.2.0.26。我应该注意到更新 XamarinAndroid build-tools 没有帮助。

这是库中的一个已知错误。在他们的论坛 here. Try to use alternate solutions from this thread and this.

中查看最新的 post

来自链接的总结:

https://www.syntaxismyui.com/xamarin-forms-masterdetail-page-navigation-recipe/

https://varunrathore.wordpress.com/2015/03/10/xamarin-forms-navigation-drawer/

http://xforms-kickstarter.com/#a-slide-out-menu-using-a-master-detail-page

http://blog.falafel.com/xamarin-creating-a-sliding-tray/

希望对您有所帮助!

我遇到了同样的问题。 以下是 Syncfusion 支持团队的回答: 报告的崩溃 "No method with name setClipOutline" 已在我们最新的 Essential Studio Volume 2 Service Pack 2, 2016(版本 14.2.0.32)中修复,可在以下 link.

下载

https://www.syncfusion.com/forums/125638/essential-studio-2016-volume-2-service-pack-release-v14-2-0-32-available-for-download

问题已解决。