question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Map renderer exception.

See original GitHub issue

Hi TK, Thanks for your great job.

I got following exception when setting up a customMap in my project. ‘’’ 12-10 16:58:52.143 I/MonoDroid(27188): UNHANDLED EXCEPTION: 12-10 16:58:52.163 I/MonoDroid(27188): System.NullReferenceException: Object reference not set to an instance of an object 12-10 16:58:52.164 I/MonoDroid(27188): at TK.CustomMap.Droid.TKCustomMapRenderer.MoveToCenter () [0x0000c] in <filename unknown>:0 12-10 16:58:52.164 I/MonoDroid(27188): at TK.CustomMap.Droid.TKCustomMapRenderer.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) [0x00015] in <filename unknown>:0 12-10 16:58:52.165 I/MonoDroid(27188): at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) [0x00008] in <filename unknown>:0 12-10 16:58:52.165 I/MonoDroid(27188): at (wrapper dynamic-method) System.Object:b029f907-c661-475e-b1ec-ddf53eca71ac (intptr,intptr,bool,int,int,int,int) 12-10 16:58:52.177 W/art (27188): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable An unhandled exception occured.

Thread finished: <Thread Pool> #3 The thread ‘<Thread Pool>’ (0x3) has exited with code 0 (0x0). 12-10 17:00:08.875 I/MonoDroid(27188): UNHANDLED EXCEPTION: Thread started: <Thread Pool> #9 12-10 17:00:08.928 I/MonoDroid(27188): System.NullReferenceException: Object reference not set to an instance of an object 12-10 17:00:08.928 I/MonoDroid(27188): at (wrapper dynamic-method) System.Object:b029f907-c661-475e-b1ec-ddf53eca71ac (intptr,intptr,bool,int,int,int,int) 12-10 17:00:08.929 I/MonoDroid(27188): at (wrapper native-to-managed) System.Object:b029f907-c661-475e-b1ec-ddf53eca71ac (intptr,intptr,int,int,int,int,int) 12-10 17:00:08.929 I/MonoDroid(27188): at (wrapper managed-to-native) System.Object:wrapper_native_0xb47b0db1 (intptr,intptr,intptr,intptr,Android.Runtime.JValue_) 12-10 17:00:08.929 I/MonoDroid(27188): at (wrapper delegate-invoke) <Module>:invoke_void_intptr_intptr_intptr_intptr_JValue_ (intptr,intptr,intptr,intptr,Android.Runtime.JValue_) 12-10 17:00:08.930 I/MonoDroid(27188): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue_ parms) [0x00060] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1025 12-10 17:00:08.930 I/MonoDroid(27188): at Xamarin.Forms.Platform.Android.FormsViewGroup.MeasureAndLayout (Int32 p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4, Int32 p5) [0x000f8] in <filename unknown>:0 12-10 17:00:08.930 I/MonoDroid(27188): at Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout () [0x000bc] in <filename unknown>:0 12-10 17:00:08.930 I/MonoDroid(27188): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].UpdateLayout () [0x00008] in <filename unknown>:0 12-10 17:00:08.931 I/MonoDroid(27188): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) [0x0003d] in <filename unknown>:0 12-10 17:00:08.931 I/MonoDroid(27188): at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) [0x00008] in <filename unknown>:0 12-10 17:00:08.932 I/MonoDroid(27188): at (wrapper dynamic-method) System.Object:b029f907-c661-475e-b1ec-ddf53eca71ac (intptr,intptr,bool,int,int,int,int) 12-10 17:00:08.932 E/art (27188): JNI NewString called with pending exception ‘md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable’ thrown in void md55b85883da287a270e8ac6f2218732aaf.TKCustomMapRenderer.n_onLayout(boolean, int, int, int, int):-2 An unhandled exception occured. ‘’’

XAML code:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:customMap="clr-namespace:TK.CustomMap;assembly=TK.CustomMap"
             xmlns:controls="clr-namespace:Test.Controls;assembly=Test"
             x:Class="Test.Views.MapPage">
  <StackLayout>
    <customMap:TKCustomMap/>
  </StackLayout>
</ContentPage>

I tested this code on your sample project and it works well.

Am i missing something?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dimeomcommented, May 10, 2016

Hi there, thank you very much for your reply! I did as you said.

But now I am getting this error:

System.MissingMethodException: Default constructor not found for type TK.CustomMap.TKCustomMap

my XAML looks like this:

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:test;assembly=test" xmlns:customMap="clr-namespace:TK.CustomMap;assembly=TK.CustomMap" x:Class="test.pageMap"> <ContentPage.Content> <Grid RowSpacing="0" ColumnSpacing="0" BackgroundColor="{DynamicResource bgColor}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> </Grid.ColumnDefinitions>

  <Grid.RowDefinitions>
    <RowDefinition Height="1*"/>
    <!--header-->
    <RowDefinition Height="7*"/>

    <RowDefinition Height="1*"/>

  </Grid.RowDefinitions>

  <!--Header-->
  <Grid RowSpacing="0" ColumnSpacing="0" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" BackgroundColor="{DynamicResource bgColor}">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="6*"/>
      <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="1*"/>
    </Grid.RowDefinitions>

    <BoxView Style="{DynamicResource boxViewHeader}" Grid.ColumnSpan="2" />
    <Image x:Name="imgLogoName" Grid.Row="0"  Grid.ColumnSpan="2" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"></Image>
    <Image x:Name="imgLogo" Grid.Column="1" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"></Image>
    <Image x:Name="imageBack" Grid.Row="0" Grid.Column="0" VerticalOptions="EndAndExpand" HorizontalOptions="StartAndExpand">
      <Image.GestureRecognizers>
        <TapGestureRecognizer
                Tapped="imageBack_Tapped"
                NumberOfTapsRequired="1" />
      </Image.GestureRecognizers>
    </Image>
  </Grid>
  <!--Header-->

  <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
      <RowDefinition Height="1*"/>

    </Grid.RowDefinitions>
    <!--<local:CustomMap Grid.Row="1" Grid.ColumnSpan="4" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"-->
    <!--<maps:Map Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
              x:Name="MyMap"
              IsShowingUser="true"
              MapType="Hybrid" />-->
    <!--<local:CustomMap x:Name="myMap" MapType="Street"
      Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" />-->
    <customMap:TKCustomMap x:Name="MyMap" MapType="Street" Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" />

  </Grid>

  <Label x:Name="lblStart" Text="Schorlejagd starten" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" VerticalOptions="FillAndExpand" HorizontalOptions="Center"></Label>

  <Image x:Name="btnStart" Grid.Row="2" Grid.Column="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
    <Image.GestureRecognizers>
      <TapGestureRecognizer
              Tapped="btnStart_Tapped"
              NumberOfTapsRequired="1" />
    </Image.GestureRecognizers>
  </Image>
</Grid>

</ContentPage.Content> </ContentPage>

and my Code:

            List<TKCustomMapPin> pins = new List<TKCustomMapPin>();
            foreach (LocationObject location in Globals.Places)
            {
                var position = new Position(double.Parse(location.Latitude.ToString()), double.Parse(location.Longitude.ToString()));
                var pin = new TKCustomMapPin();
                pin.Position = position;
                pin.Title = location.Name;
                pin.Image = Device.OnPlatform("icon.png", "icon.png", "Assets/icon.png");

                pins.Add(pin);
            }

            MyMap.CustomPins = pins;

maybe I am missing something?

0reactions
TorbenKcommented, May 10, 2016

Hi,

use CustomPins. Please check the samples.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xamarin.Forms Map renderer error : r/xamarindevelopers
Hello, I come to you with an exception that is triggered randomly on my map android renderer. I have ovveriden the method OnLayout(bool ......
Read more >
Xamarin Android Map Renderer Exception 2.3.4
I'm getting an exception while invoking the MoveToRegion call. It looks like it is internal. Has anyone else seen this? Xamarin.Forms MapRenderer: ...
Read more >
How to map and log exceptions but still have SpringBoot ...
I want to use the original SpringBoot JSON error message though which is probably made by the DefaultErrorAttributes class. Any ideas? spring- ...
Read more >
Exception on apex:map when re-rendering
Hi, When re-rendering the parent element of a apex:map, I get this error message displayed instead of the map:
Read more >
JavaScript exception while using renderer on sublayers
I have a strange exception in my implementation. The problem is when there is a popup in display, and if I want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found