amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 346 forks source link

Java.Lang.ClassCastException #686

Closed woemike closed 4 years ago

woemike commented 4 years ago

VERSIONS

PLATFORMS

ACTUAL BEHAVIOR

I have a project where I need to implement a map. I decided to go for GoogleMaps using this nugget, however I get this error: Java.Lang.ClassCastException: 'android.widget.ImageView cannot be cast to android.view.ViewGroup'. First time it works fine. When the app is killed and started again, it does not work anymore.

ACTUAL SCREENSHOTS/STACKTRACE

// paste stacktrace Java.Lang.ClassCastException: 'android.widget.ImageView cannot be cast to android.view.ViewGroup'

EXPECTED BEHAVIOR

No crash when running the app twice.

HOW TO REPRODUCE

  1. Install Xamarin.Forms - 4.4.0.991265 and Xamarin.Forms.GoogleMaps - 3.3.0.
  2. Implement map using this nugget.
  3. Start app twice.

// code for reproduce
private void InitializeGoogleMaps()
{
    googleMapsView.MapType = Xamarin.Forms.GoogleMaps.MapType.Street;
    googleMapsView.MyLocationEnabled = true;
    googleMapsView.UiSettings.MyLocationButtonEnabled = true;
    googleMapsView.UiSettings.ZoomControlsEnabled = false;
    googleMapsView.UiSettings.CompassEnabled = false;
    googleMapsView.UiSettings.RotateGesturesEnabled = true;
}

// XAML
<!-- GoogleMaps View -->
<maps:Map x:Name="googleMapsView" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" 
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=1}" 
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=1}" 
IsVisible="{Binding IsGoogleMapsEnabled}"/>
jahmai-ca commented 1 year ago

@woemike Sorry for resurrecting this issue, but hello from 2022! I am experiencing this issue. Did you ever resolve it?