0

In my forms project, when navigating to the shell page from content page , i am getting Unhandled Exception: Android.Views.InflateException: <Timeout exceeded getting exception details> . I am using visualstudio 2017 community version.Important thing is there is no error when using visualstudio 2019 community edition.This happened after merging with a sub branch.I have tried deleting bin,obj folders, downgrading xamarin version etc.Nothing found useful.I am stuck at this point.Please help...

AppShell.xaml

<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:d="http://xamarin.com/schemas/2014/forms/design"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       mc:Ignorable="d" 
       FlyoutBehavior="Flyout"
       FlyoutIsPresented="True"
       xmlns:local="clr-namespace:WeCareMobility.Views"          
       Title="WeCareMobility" FlyoutBackgroundColor="DarkBlue"
       x:Class="WeCareMobility.AppShell">

    <!--Styles and Resources-->

    <Shell.Resources>
        <ResourceDictionary>
            <Color x:Key="NavigationPrimary">#002060</Color>
            <Style x:Key="BaseStyle" TargetType="Element">
                <Setter Property="Shell.BackgroundColor" Value="{StaticResource NavigationPrimary}" />
                <Setter Property="Shell.ForegroundColor" Value="White" />
                <Setter Property="Shell.TitleColor" Value="White" />
                <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
                <Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
                <Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource NavigationPrimary}" />
                <Setter Property="Shell.TabBarForegroundColor" Value="White"/>
                <Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
                <Setter Property="Shell.TabBarTitleColor" Value="White"/>
            </Style>
            <Style TargetType="ShellItem" BasedOn="{StaticResource BaseStyle}" />
        </ResourceDictionary>
    </Shell.Resources>

    <ShellItem  >
        <ShellSection>
            <ShellContent>
                <local:HomePage />
            </ShellContent>
        </ShellSection>
    </ShellItem>
<Shell.FlyoutHeaderTemplate>
        <DataTemplate>
            <Grid Padding="10" BackgroundColor="White" HorizontalOptions="CenterAndExpand">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Image Source="steering_logo.png"/>
                <Label Grid.Column="1" Text="Copiloto" FontSize="Large" FontAttributes="Bold" TextColor="Black" VerticalOptions="Center"/>
            </Grid>
        </DataTemplate>
    </Shell.FlyoutHeaderTemplate>
    <Shell.ItemTemplate>
        <DataTemplate>
            <Grid Padding="10" BackgroundColor="Transparent">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Button Text="Change language" Clicked="Lan_Btn_Clicked" Style="{StaticResource FlyoutButtonStyle}"/>
                <Button Grid.Row="1" Text="Trip History" Clicked="LblTripHis_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
                <Button Grid.Row="2" Text="Select Vehicle" Clicked="SelectVehicleTapped" Style="{StaticResource FlyoutButtonStyle}"/>
                <Button Grid.Row="3" Text="Ask a service" Clicked="Service_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
                <Button Grid.Row="4" Text="Bluetooth Connection" Clicked="Connection_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
                <Button Grid.Row="5" Text="Change Password" Clicked="ResetPasswordTapped" Style="{StaticResource FlyoutButtonStyle}"/>
                <Button Grid.Row="6" Text="About Us" Clicked="AboutUs_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
            </Grid>
        </DataTemplate>
    </Shell.ItemTemplate>
</Shell>

AppShell.xaml.cs

namespace WeCareMobility
{
    public partial class AppShell : Xamarin.Forms.Shell
    {       
        public AppShell()
        {
            InitializeComponent();               
        }                                      
    }

HomePage.xaml

<ScrollView>         
            <Label VerticalOptions="StartAndExpand" HorizontalOptions="CenterAndExpand" Margin="0,30,0,0" FontSize="Medium" FontAttributes="Bold">
                <Label.FormattedText>
                    <FormattedString>
                        <Span Text="{i18n:Translate Speed}" />
                        <Span Text="{Binding CurrentSpeed , StringFormat=' :  {0:F1} km/h '}" />
                    </FormattedString>
                </Label.FormattedText>
            </Label>


            <Label Text="{Binding VehicleName}" TextColor="Black" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
                <Label.GestureRecognizers>
                    <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
                </Label.GestureRecognizers>
            </Label>

            <Frame Grid.Row="1" BackgroundColor="White" CornerRadius="10" HasShadow="True" HorizontalOptions="FillAndExpand">
                <Grid Margin="5,5,5,0" ColumnSpacing="10" RowSpacing="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <Label Grid.ColumnSpan="2" Text="{i18n:Translate Scoring}" FontAttributes="Bold"/>
                    <Label Grid.Column="2" Text="Month" FontSize="Small" TextColor="SkyBlue" HorizontalOptions="End"/>
                    <Image Grid.Column="3" Source="triangle.png" HeightRequest="15" WidthRequest="15" HorizontalOptions="Start"/>
                    <StackLayout Grid.Row="1" Grid.ColumnSpan="4" HorizontalOptions="FillAndExpand" Margin="0,0,0,10">
                        <!--<chart:SfChart>
                            <chart:SfChart.Title>
                            <chart:ChartTitle Text="Project Cost Breakdown"/>
                        </chart:SfChart.Title>
                            <chart:SfChart.BindingContext>
                                <viewmodel:DoughnutSeriesViewModel />
                            </chart:SfChart.BindingContext>
                            <chart:SfChart.Legend>
                                <chart:ChartLegend IconHeight="0" IconWidth="0" DockPosition="Bottom" />
                            </chart:SfChart.Legend>
                            <chart:SfChart.Series>
                                <chart:DoughnutSeries ItemsSource="{Binding DoughnutSeriesData}" XBindingPath="Name" YBindingPath="Value" TrackBorderColor="{Binding TrackColor}" LegendIcon="None" IsVisibleOnLegend="False" DoughnutCoefficient="0.8">
                                    <chart:DoughnutSeries.DataMarker>
                                        <chart:ChartDataMarker ShowLabel="False">
                                            <chart:ChartDataMarker.LabelStyle>
                                                <chart:DataMarkerLabelStyle LabelFormat="##'M'"/>
                                            </chart:ChartDataMarker.LabelStyle>
                                        </chart:ChartDataMarker>
                                    </chart:DoughnutSeries.DataMarker>
                                    <chart:DoughnutSeries.ColorModel>
                                        <chart:ChartColorModel Palette="Natural" />
                                    </chart:DoughnutSeries.ColorModel>
                                    <chart:DoughnutSeries.CenterView>
                                        <Label Text="50" TextColor="Black" FontAttributes="Bold" FontSize="30" FontFamily="Helvetica" HorizontalTextAlignment="Center"/>
                                    </chart:DoughnutSeries.CenterView>
                                </chart:DoughnutSeries>
                            </chart:SfChart.Series>
                        </chart:SfChart>-->
                    </StackLayout>
                    <Label Grid.Row="2" Text="Best Grade" FontAttributes="Bold"/>
                    <Label Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Text="Worst Grade" FontAttributes="Bold"/>
                    <Label Grid.Row="3" Text="Cornering"/>
                    <Label Grid.Row="3" Grid.Column="1" Text="Phone Distraction" Grid.ColumnSpan="2"/>
                </Grid>
            </Frame>

            <Frame Grid.Row="2" BackgroundColor="White" CornerRadius="10" HasShadow="True" HorizontalOptions="FillAndExpand">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <!--<ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>-->
                    </Grid.ColumnDefinitions>

                    <Label Grid.ColumnSpan="9" Text="Current Trip" FontAttributes="Bold"/>
                    <Image Grid.Row="1" Grid.ColumnSpan="9" Source="wecare_map.png" HorizontalOptions="FillAndExpand"/>
                    <Label Grid.Row="2" Grid.ColumnSpan="9" Text="Holborn, London UK"/>
                    <Label Grid.Row="3" Text="Distance" FontSize="12"/>
                    <Label Grid.Row="3" Grid.Column="1" Text="120" FontSize="12"/>
                    <Label Grid.Row="3" Grid.Column="2" Text="km" FontAttributes="Bold" FontSize="12"/>
                    <!--<Label Grid.Row="3" Grid.Column="3" Text="m" TextColor="Transparent" BackgroundColor="Transparent"/>-->
                    <Label Grid.Row="3" Grid.Column="3" Text="1h02" FontAttributes="Bold" HorizontalOptions="End" FontSize="12"/>
                    <Label Grid.Row="3" Grid.Column="4" Text="Duration" HorizontalOptions="Start" FontSize="12"/>
                    <!--<Label Grid.Row="3" Grid.Column="6" Text="m" TextColor="Transparent" BackgroundColor="Transparent" HorizontalOptions="Start"/>-->
                    <Label Grid.Row="3" Grid.Column="5" Text="3" FontAttributes="Bold" HorizontalOptions="End" FontSize="12"/>
                    <Image Grid.Row="3" Grid.Column="6" Source="error.png" HeightRequest="15" WidthRequest="15" HorizontalOptions="Start"/>
                </Grid>
            </Frame>

            <Frame Grid.Row="3" BackgroundColor="DarkBlue" CornerRadius="10" HasShadow="True" HorizontalOptions="FillAndExpand">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <Label Text="Summary" TextColor="White" FontAttributes="Bold"/>
                    <Label Grid.Column="1" Text="Month" FontSize="Small" TextColor="SkyBlue" HorizontalOptions="End"/>
                    <Image Grid.Column="2" Source="triangle.png" HeightRequest="15" WidthRequest="15" HorizontalOptions="Start"/>

                    <!--<flv:FlowListView Grid.Row="2" Grid.ColumnSpan="3" FlowColumnCount="2" SeparatorVisibility="None" HasUnevenRows="True"
                                  FlowItemsSource="{Binding TempList}">
                    <flv:FlowListView.FlowColumnTemplate>
                        <DataTemplate>
                            <Frame BackgroundColor="Transparent">
                                <Grid RowSpacing="0">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                    <Image Grid.RowSpan="2" Source="{Binding ImgSource}" HeightRequest="20"/>
                                    <Label Grid.Column="1" Text="{Binding Header}" FontSize="12"/>
                                    <Label Grid.Row="1" Grid.Column="1" Text="{Binding Detail}" FontSize="8"/>
                                </Grid>
                            </Frame>
                        </DataTemplate>
                    </flv:FlowListView.FlowColumnTemplate>
                </flv:FlowListView>-->

                    <!--<flv:FlowListView x:Name="listview" HasUnevenRows="true" FlowColumnCount="2" FlowItemsSource="{Binding TempList}"
                          BackgroundColor="#ECD2FC">

                    <flv:FlowListView.FlowColumnTemplate>
                        <DataTemplate>
                            <Frame HasShadow="True" OutlineColor="Red" Margin="2">
                                <StackLayout>
                                    <Label Text="Test" FontSize="20" FontAttributes="Bold"/>
                                </StackLayout>
                            </Frame>
                        </DataTemplate>
                    </flv:FlowListView.FlowColumnTemplate>

                </flv:FlowListView>-->

                    <!--<ListView Grid.Row="2" Grid.ColumnSpan="2" ItemsSource="{Binding TempList}">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Grid RowSpacing="0">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Image Grid.RowSpan="2" Source="{Binding ImgSource}"/>
                                    <Label Grid.Column="1" Text="{Binding Header}"/>
                                    <Label Grid.Row="1" Grid.Column="1" Text="{Binding Detail}"/>
                                </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>-->

                    <FlexLayout Grid.Row="2" Grid.ColumnSpan="2" BindableLayout.ItemsSource="{Binding TempList}" 
                            Wrap="Wrap" Direction="Row" FlowDirection="LeftToRight" JustifyContent="Start" AlignItems="Start">
                        <BindableLayout.ItemTemplate>
                            <DataTemplate>
                                <Frame BackgroundColor="Transparent">
                                    <Grid RowSpacing="0">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.RowSpan="2" Source="{Binding ImgSource}" HeightRequest="22"/>
                                        <Label Grid.Column="1" Text="{Binding Header}" FontSize="13" TextColor="White"/>
                                        <Label Grid.Row="1" Grid.Column="1" Text="{Binding Detail}" FontSize="9" TextColor="White"/>
                                    </Grid>
                                </Frame>
                            </DataTemplate>
                        </BindableLayout.ItemTemplate>
                    </FlexLayout>                   

                </Grid>
            </Frame>
        </Grid>
    </ScrollView>
    <Frame  BackgroundColor="Green" HorizontalOptions="FillAndExpand" VerticalOptions="EndAndExpand">
        <Label Text="Page under Development" HorizontalOptions="CenterAndExpand" FontSize="Medium" TextColor="White"/>
    </Frame>

HomePage ViewModel:

public HomePageViewModel(Page page) : base(page)
    {
        _BeaconList = new List<Features.Home.Beacon>();            
        TranslateCommand = new Command(translate);
        tripstart = false;
        if (TripCollection == null)
        {
            TripCollection = new List<Trip>();
        }   

    }      

    public override void Init()
    {
        IsInitialized = true;
        if(BeaconPageViewModel.ConnectedVehicle != null)
        {
            VehicleName = BeaconPageViewModel.ConnectedVehicle;
            DetectSpeed();
        }
        else
        {
            VehicleName = "No Vehicle";
        }
  }    

    private async void DetectSpeed()
    {
        var sunday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek);
        try
        {
            var hasPermission = await Utils.CheckPermissions(Permission.Location);
            if (!hasPermission)
                return;    
            if (tracking)
            {
                CrossGeolocator.Current.PositionChanged -= CrossGeolocator_Current_PositionChanged;
                CrossGeolocator.Current.PositionError -= CrossGeolocator_Current_PositionError;
            }
            else
            {
                CrossGeolocator.Current.PositionChanged += CrossGeolocator_Current_PositionChanged;
                CrossGeolocator.Current.PositionError += CrossGeolocator_Current_PositionError;
            }

            if (CrossGeolocator.Current.IsListening)
            {
                await CrossGeolocator.Current.StopListeningAsync();
                tracking = false;
            }
            else
            {
                if (await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 1,
                   false, new ListenerSettings
                   {
                       AllowBackgroundUpdates = true,
                       DeferLocationUpdates = true,
                       DeferralDistanceMeters = 1,
                       DeferralTime = TimeSpan.FromSeconds(1),
                       ListenForSignificantChanges = true,
                       PauseLocationUpdatesAutomatically = true
                   }))
                {
                    tracking = true;
                }
            }
        }
        catch (Exception ex)
        {
            await App.Current.MainPage.DisplayAlert("Uh oh", "Something went wrong, but don't worry we captured for analysis! Thanks.", "OK");
        }
    }    
    void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e)
    {
        ticks++;
        tripPoints = new TripPoints();

        var position = e.Position;
        var speedms = position.Speed;
        _kmh = speedms * 3.6;

        if (_kmh > 3.00)
        {
            count++ ;
            if (count > 11)
            {
                if (!tripstart)
                {
                    tripstart = true;
                    DependencyService.Get<IToast>().LongAlert("Trip started");
                    DateTime dateAndTime = DateTime.Now;
                    trip = new Trip();
                    trip.StartDate = DateTime.Now;
                    trip.StartTime = dateAndTime.ToString("hh:mm tt");
                    trip.TripPointList = new List<TripPoints>();
                }
                CurrentSpeed = _kmh.ToString("N2");
                OnPropertyChanged("CurrentSpeed");
                App.Current.Properties.Remove("Zerotime");                
            }
        }
        else if (_kmh < 1.00)
        {
            CurrentSpeed = _kmh.ToString("N2");
            OnPropertyChanged("CurrentSpeed");
            var lasttime = DateTime.Now;
            if (App.Current.Properties.ContainsKey("Zerotime"))
            {
                var zerotime = (DateTime)App.Current.Properties["Zerotime"];
                var SecondDifference = (lasttime - zerotime).TotalSeconds;
                if (SecondDifference > 119)
                {
                    if (tripstart == true)
                    {
                        DependencyService.Get<IToast>().LongAlert("Trip stopped");
                        tripstart = false;
                        count = 0;
                        DateTime dateAndTime = DateTime.Now;
                        //    trip.EndDate = dateAndTime.ToShortDateString();
                        trip.EndDate = DateTime.Now;
                        trip.EndTime = dateAndTime.ToString("hh:mm tt");
                        trip.Distance = TotalDistance;

                        TripCollection.Add(trip);
                    }
                }
            }
            else
            {
                App.Current.Properties["Zerotime"] = DateTime.Now;
            }    
        }    
    }   

Exception Details:

    09-14 21:31:00.177 I/MonoDroid( 3357): UNHANDLED EXCEPTION:
    09-14 21:31:00.202 I/MonoDroid( 3357): Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class xamarin.forms.platform.android.appcompat.FormsViewPager ---> Android.Views.InflateException: Binary XML file line #1: Error inflating class xamarin.forms.platform.android.appcompat.FormsViewPager ---> Java.Lang.ClassNotFoundException: Didn't find class "xamarin.forms.platform.android.appcompat.FormsViewPager" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/lib/arm64, /data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk!/lib/arm64-v8a, /system/lib64]]
    Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class xamarin.forms.platform.android.appcompat.FormsViewPager
09-14 21:31:00.371 F/.WeCareMobilit( 3357): java_vm_ext.cc:542]   at android.view.View  
09-14 21:31:00.372 F/.WeCareMobilit( 3357): java_vm_ext.cc:542] Caused by: java.lang.ClassNotFoundException: Didn't find class "xamarin.forms.platform.android.appcompat.FormsViewPager" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/lib/arm64, /data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk!/lib/arm64-v8a, /system/lib64]]
09-14 21:31:00.372 F/.WeCareMobilit( 3357): java_vm_ext.cc:542] (Throwable with no stack trace)
Vipin Krishna
  • 355
  • 1
  • 4
  • 25

0 Answers0