ThinkGeo.com    |     Documentation    |     Premium Support

OSM on Android HowDoI sample throws error

Hi

I have opened the How Do I example with VS 2017 and run it on a Samsung S6 (have not tested on other devices). The app deploys successfully but when I try to open the item “Overlays and layers -> User OpenStreetMap Overlay” the app crashes and I get the error from VS “Object reference not set to an instance of an object”. I looked to the output windows and see this error:
( 8209): — SkAndroidCodec::NewFromStream returned null
System.NullReferenceException: Object reference not set to an instance of an object.

The code in the example is relatively simple

  protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.DisplayMapView);

        OpenStreetMapOverlay osmOvelerlay = new OpenStreetMapOverlay();

        androidMap = FindViewById<MapView>(Resource.Id.androidmap);
        androidMap.MapUnit = GeographyUnit.Meter;
        androidMap.ZoomLevelSet = new SphericalMercatorZoomLevelSet();
        androidMap.CurrentExtent = osmOvelerlay.GetBoundingBox();
        androidMap.Overlays.Add(osmOvelerlay);

        SampleViewHelper.InitializeInstruction(this, FindViewById<RelativeLayout>(Resource.Id.MainLayout), GetType());
    }

Hi Hannes,

After get the sample from GitHub, please upgrade all the packages to the latest version.

If you have upgraded it, please delete the packages, bin, obj folder and upload the project here, so we can try to reproduce it based on the sample. We need it instead of get it from GitHub is because we don’t know whether you modified code or not and which detail package you are using now, that can saved the communication time.

Regards,

Ethan

Hi Ethan

I have downloaded from Github and upgraded all the nuget packages but it gives the same error.

Find attached the downloaded solution without the packages, bin and obj folders. Also note that I had to delete all the files in Assets -> AppData. The zipped file is 6MB with the AppData and it is too large to upload here.
Downloaded_HowDoI_2018_06_04 (2).zip (1.6 MB)

Hi Hannes,

Thanks for your sample, our developer tested it and suggest please upgrade all package to the v11 beta version(development version) and it will works.

Regards,

Ethan