0

I have coded a Google Maps application in Xamarin, and am getting this error:

Android.Views.InflateException: Binary XML file line #1: Error inflating class fragment

I am getting this error when the following line of code is run:

SetContentView(Resource.Layout.MapWithOverlayLayout);

Here is my MapWithOverlayLayout.axml layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
  <fragment class="SimpleMapDemo.MapWithMarkersActivity"
            android:id="@+id/mapWithOverlay"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
</LinearLayout>

The namespace is called: SimpleMapDemo

Here is my class declaration:

public class MapWithMarkersActivity : Android.Support.V4.App.FragmentActivity

I am using a SupportMapFragment object to display a Google Map

Can I please have some help to get this code working?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user3548779
  • 321
  • 2
  • 8
  • 19

3 Answers3

0

I think the problem is with the class attribute you set on the fragment element. Have you tired inflating the layout without it?

leafartist
  • 613
  • 1
  • 5
  • 12
0

I have figured it out myself. I did not have the correct class name.

Here is the correct layout code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
user3548779
  • 321
  • 2
  • 8
  • 19
-1

I had the same problem and fixed it by deleting the AndroidManifest in the obj/Debug/android directory, in the VS or XS and rewriting it so that it only works on me

That is because the app can't distinguish between google play services manifest and the app's one.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222