Question

I am using Xamarin and am learning the SimpleMapDemo sample code for creating a Google Maps application.

The following variable is declared:

private MapFragment _mapFragment;

How can I change this variable to be SupportMapFragment instead of MapFragment?

I am getting this error:

Error CS0246: The type or namespace name 'SupportMapFragment' could not be found (are you missing a using directive or an assembly reference?)

Thanks in advance

Was it helpful?

Solution

Instead of declaring

private MapFragment _mapFragment;

do

private SupportMapFragment _mapFragment;

Also make sure that

  1. you have imported android.support.v4.app.Fragment
  2. you have android.support.v4.jar in your libs folder and in the project build path

Copy android.support.v4.jar into a lib/ folder inside of your project.

Now select the jar file in that folder, right click -> Build Path -> Add To Build Path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top