Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin在android上形成导致崩溃的MasterDetail页面导航[致命信号6(SIGABRT),代码-6],在iOS和UWP上工作_Android_Xamarin_Mvvm_Xamarin.forms_Master Detail - Fatal编程技术网

Xamarin在android上形成导致崩溃的MasterDetail页面导航[致命信号6(SIGABRT),代码-6],在iOS和UWP上工作

Xamarin在android上形成导致崩溃的MasterDetail页面导航[致命信号6(SIGABRT),代码-6],在iOS和UWP上工作,android,xamarin,mvvm,xamarin.forms,master-detail,Android,Xamarin,Mvvm,Xamarin.forms,Master Detail,我有一个主细节如下 public partial class LeaguesMDPage : MasterDetailPage { public LeaguesMDPage() { InitializeComponent(); Master = new LeaguesPage(); Detail = new NavigationPage(new DivisionsPage(new League())); } } &

我有一个主细节如下

public partial class LeaguesMDPage : MasterDetailPage
{
    public LeaguesMDPage()
    {
        InitializeComponent();
        Master = new LeaguesPage();
        Detail = new NavigationPage(new DivisionsPage(new League()));
    }
}
    <ListView
    ItemsSource="{Binding Leagues}"
    SelectedItem="{Binding SelectedLeague, Mode=TwoWay}"
    IsPullToRefreshEnabled="True"
    RefreshCommand="{Binding UpdateLeagues}"
    IsRefreshing="{Binding IsBusy}"
    >
联盟页面(主)设计有如下列表视图

public partial class LeaguesMDPage : MasterDetailPage
{
    public LeaguesMDPage()
    {
        InitializeComponent();
        Master = new LeaguesPage();
        Detail = new NavigationPage(new DivisionsPage(new League()));
    }
}
    <ListView
    ItemsSource="{Binding Leagues}"
    SelectedItem="{Binding SelectedLeague, Mode=TwoWay}"
    IsPullToRefreshEnabled="True"
    RefreshCommand="{Binding UpdateLeagues}"
    IsRefreshing="{Binding IsBusy}"
    >
在LeagueViewModel中,我让SelectedLeague属性设置器更新详细信息页面并像这样隐藏主视图

League _SelectedLeague;

public League SelectedLeague
{
    get { return _SelectedLeague; }
    set
    {
        _SelectedLeague = value;
        OnPropertyChanged();
        if (_SelectedLeague != null)
        {
            Debug.WriteLine($"Navigating to DivisionsPage with LeagueID {_SelectedLeague.ID}");
            var mdp = (MasterDetailPage)App.Current.MainPage;
            Device.OnPlatform(                     
                    Android: () => { mdp.IsPresented = false; },
                    iOS: () => { mdp.IsPresented = false; },
                    WinPhone: () => { },
                    Default: () => { mdp.IsPresented = false; }
                );
            mdp.Detail = new NavigationPage(new DivisionsPage(_SelectedLeague));
            _SelectedLeague = null;
        }
    }
}
这似乎确实像我有时希望的那样起作用。它将导航到新分区并隐藏主分区。在iOS和UWP上似乎工作得很好,但在安卓系统上它崩溃了,原因如下

[0:] Server Returned 34 divisions
[0:] Navigating to DivisionsPage with LeagueID 12
[0:] UpdatePoolRankings: Called GetDivisionsAsync
03-23 02:40:52.151 W/Mono    ( 6249): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
03-23 02:40:52.151 D/Mono    ( 6249): Unloading image System.Core.dll [0x99db7700].
03-23 02:40:52.151 D/Mono    ( 6249): Image addref System.Core[0xaec169a0] -> System.Core.dll[0x9d166d00]: 11
03-23 02:40:52.151 D/Mono    ( 6249): Config attempting to parse: 'System.Core.dll.config'.
03-23 02:40:52.151 D/Mono    ( 6249): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/System.Core/System.Core.config'.
03-23 02:40:52.152 W/Mono    ( 6249): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
03-23 02:40:52.152 D/Mono    ( 6249): Unloading image System.Core.dll [0x99db7700].
03-23 02:40:52.152 D/Mono    ( 6249): Image addref System.Core[0xaec169a0] -> System.Core.dll[0x9d166d00]: 12
03-23 02:40:52.152 D/Mono    ( 6249): Config attempting to parse: 'System.Core.dll.config'.
03-23 02:40:52.152 D/Mono    ( 6249): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/System.Core/System.Core.config'.
03-23 02:40:52.383 D/Mono    ( 6249): [0x9b5bf930] hill climbing, change max number of threads 4
[0:] Server Returned 3 divisions
03-23 02:40:52.421 F/        ( 6249): * Assertion at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mono/metadata/sgen-tarjan-bridge.c:1139, condition `xref_count == xref_index' not met
03-23 02:40:52.421 F/libc    ( 6249): Fatal signal 6 (SIGABRT), code -6 in tid 6249 (ClubApp.Droid)
InspectorDebugSession(21): Disposed
InspectorDebugSession(21): HandleTargetEvent: TargetExited

如果需要更多细节,请告诉我,谢谢

我将您的示例更新为2.3.4的最新版本,它在Android上运行,没有问题。我建议您删除MasterDetailPage中的代码,并将其更新为以下内容:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:ClubApp.Views;assembly=ClubApp"
             xmlns:model="clr-namespace:ClubApp.Models;assembly=ClubApp"
             x:Class="ClubApp.Views.MainMasterDetailPage" 
             Title="MD Page"
             IsPresented="True">
    <MasterDetailPage.Master>
        <local:LeaguesPage />
    </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
        <NavigationPage>
            <x:Arguments>
                <local:DivisionsPage>
                    <x:Arguments>
                        <model:League />
                    </x:Arguments>
                </local:DivisionsPage>
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>
</MasterDetailPage>

我遇到了一个类似的问题,这是由导航页面的android渲染器中的一个bug引起的。 看看这个,这里有一个链接的bug报告和一个解决方法。这个问题应该在当前的XamForms版本中修复


您可以尝试省去NavigationPage(直接将您的分区设置为详细信息)要找出是导航页面导致了崩溃。

您能分享一个可以重现此问题的基本演示吗?@ElvisXia MSFT这里是一个简化版本,但我已经能够重现此问题,以便重新发布。请确保使用android,并在一个循环中不断单击打开主机,然后从列表中选择,打开主机,从主列表中选择等等,直到Crassesi发现另一个人有这个问题,我想这是因为它来自mono内部,我有完全相同的问题!在我的例子中,我也使用主细节。在我的详细信息中,我有一个ListView,它可以导航到另一个包含ListView的页面。当我返回时,有时应用程序会崩溃,并显示完全相同的消息。我正在使用Xamarin表单您可以使用Xamarin表单解决此问题(我没有测试您的解决方案)。(本地)Xamarin Android应用程序也存在该漏洞。你有解决这个问题的办法吗?你没有张贴非表格复印件。如果你的问题是表单应用程序,那么根据你的示例,你只需要更新到最新的稳定版本。我不是OP(但我启动了bounty)。我只是对一个非表单应用程序也有同样的问题,我想你可能知道可能会转移到我的案例中的潜在问题。如果你发布一个复制程序,我可以看看这里是一个示例应用程序:来回17次后它崩溃了(我的Lg G4c是17次,而Galaxy S6是30次,但总是相同的数量)。