Multiple Errors after updating NuGet Packages of an 3 year old Xamarin App

59 Views Asked by At

I opened an old abandoned project on my computer(about 2-3 years old) on Visual Studio. I debugged the application and seemed to be in a working condition except for a few small problems(related to the code)

So I updated my packages: enter image description here

And now I've over 62 errors and multiple problems in my code which were working when I first developed it and when I'd just opened it for the first time in an older Visual Studio version, now I'd assume that some things might have changed and I'm willing to look into that. But I'm overwhelmed with 62 errors for a project that I'm not well-versed with anymore. I've no idea which reference library I'm missing.

Severity    Code    Description Project File    Line    Suppression State
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 16  Active
Error   CS0246  The type or namespace name 'ExportRendererAttribute' could not be found (are you missing a using directive or an assembly reference?)   Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 13  Active
Error   CS0246  The type or namespace name 'ExportRenderer' could not be found (are you missing a using directive or an assembly reference?)    Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 13  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 16  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 16  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 18  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 18  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 20  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 24  Active
Error   CS0234  The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform' (are you missing an assembly reference?)  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 24  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 24  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 40  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 48  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 48  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 58  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 75  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 75  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 114 Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 114 Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 119 Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 119 Active
Error   CS0234  The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform' (are you missing an assembly reference?)  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\MainActivity.cs  13  Active
Error   CS0012  The type 'ElementChangedEventArgs<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.    Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 26  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 26  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 30  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 35  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 42  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 44  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 45  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 50  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 51  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 54  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 54  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 60  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 63  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 63  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 68  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 69  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 69  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 69  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 70  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 71  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 77  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 77  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 77  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 80  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 82  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 85  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 85  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 90  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 94  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 97  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 97  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 98  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 98  Active
Error   CS0012  The type 'ViewRenderer<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\CustomMapRenderer.cs 121 Active
Error   CS0103  The name 'TabLayoutResource' does not exist in the current context  Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\MainActivity.cs  17  Active
Error   CS0103  The name 'ToolbarResource' does not exist in the current context    Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\MainActivity.cs  18  Active
Error   CS0234  The type or namespace name 'Platform' does not exist in the namespace 'Xamarin.Essentials' (are you missing an assembly reference?) Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\MainActivity.cs  22  Active
Error   CS0234  The type or namespace name 'Forms' does not exist in the namespace 'Xamarin.Forms' (are you missing an assembly reference?) Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\MainActivity.cs  23  Active
Error   CS0103  The name 'LoadApplication' does not exist in the current context    Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\MainActivity.cs  24  Active
Error   CS0234  The type or namespace name 'Platform' does not exist in the namespace 'Xamarin.Essentials' (are you missing an assembly reference?) Orbage.Android  C:\Users\Mohammed\Downloads\orbagebackup2\Orbage\Orbage\Orbage.Android\MainActivity.cs  28  Active
Warning     Google Play requires that new applications and updates must use a TargetFrameworkVersion of v11.0 (API level 30) or above. You are currently targeting v10.0 (API level 29).    Orbage.Android          

The errors start from here:

CustomMapRenderer.cs:

using System;
using System.Collections.Generic;
using Android.Content;
using Android.Gms.Maps;
using Android.Gms.Maps.Model;
using Android.Widget;
using Orbage;
using Orbage.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
using Xamarin.Forms.Maps.Android;

[assembly: ExportRenderer(typeof(CustomMap), typeof(CustomMapRenderer))]
namespace Orbage.Droid
{
    public class CustomMapRenderer : MapRenderer, GoogleMap.IInfoWindowAdapter
    {
        List<CustomPin> customPins;

        public CustomMapRenderer(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Map> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                NativeMap.InfoWindowClick -= OnInfoWindowClick;
            }

            if (e.NewElement != null)
            {
                var formsMap = (CustomMap)e.NewElement;
                customPins = formsMap.CustomPins;
            }
        }

        protected override void OnMapReady(GoogleMap map)
        {
            base.OnMapReady(map);

            NativeMap.InfoWindowClick += OnInfoWindowClick;
            NativeMap.SetInfoWindowAdapter(this);
        }

        protected override MarkerOptions CreateMarker(Pin pin)
        {
            var marker = new MarkerOptions();
            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);
            marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));
            return marker;
        }

        void OnInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
        {
            var customPin = GetCustomPin(e.Marker);
            if (customPin == null)
            {
                throw new Exception("Custom pin not found");
            }

            if (!string.IsNullOrWhiteSpace(customPin.Url))
            {
                var url = Android.Net.Uri.Parse(customPin.Url);
                var intent = new Intent(Intent.ActionView, url);
                intent.AddFlags(ActivityFlags.NewTask);
                Android.App.Application.Context.StartActivity(intent);
            }
        }

        public Android.Views.View GetInfoContents(Marker marker)
        {
            var inflater = Android.App.Application.Context.GetSystemService(Context.LayoutInflaterService) as Android.Views.LayoutInflater;
            if (inflater != null)
            {
                Android.Views.View view;

                var customPin = GetCustomPin(marker);
                if (customPin == null)
                {
                    throw new Exception("Custom pin not found");
                }

                if (customPin.Name.Equals("Xamarin"))
                {
                    view = inflater.Inflate(Resource.Layout.XamarinMapInfoWindow, null);
                }
                else
                {
                    view = inflater.Inflate(Resource.Layout.MapInfoWindow, null);
                }

                var infoTitle = view.FindViewById<TextView>(Resource.Id.InfoWindowTitle);
                var infoSubtitle = view.FindViewById<TextView>(Resource.Id.InfoWindowSubtitle);

                if (infoTitle != null)
                {
                    infoTitle.Text = marker.Title;
                }
                if (infoSubtitle != null)
                {
                    infoSubtitle.Text = marker.Snippet;
                }

                return view;
            }
            return null;
        }

        public Android.Views.View GetInfoWindow(Marker marker)
        {
            return null;
        }

        CustomPin GetCustomPin(Marker annotation)
        {
            var position = new Position(annotation.Position.Latitude, annotation.Position.Longitude);
            foreach (var pin in customPins)
            {
                if (pin.Position == position)
                {
                    return pin;
                }
            }
            return null;
        }
    }
}

This is the documentation I'd referred to while I'd made this: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/map-pin However this article has not been updated ever since I referred to it, so I'm unable to find out any obvious problems.

1

There are 1 best solutions below

1
Yannick On

Had the same issues. I looked at the csproject file in a editor and saw that there was a package reference added to Xamarin.Forms.Platform.IOS to my Android Project.

Removed that and it worked fine :)