Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

'Error inflating class fragment' error when following Maps API tutorial

$
0
0

Hi all,

I've been following the Maps API tutorial and am consistantly running into problems. The most consistent of which is 'Android.Views.InflateException'. I have followed the toturial to the absolute letter, yet cannot find what the issue is.

The project will not build at all.

MainActivity.cs:

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace NewMapApp
{
    [Activity (Label = "NewMapApp", MainLauncher = true)]
    public class MainActivity : Activity
    {
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // the below causes errors due to 'MapFragment does not exist in the current context' 
//          _myMapFragment = MapFragment.NewInstance();
//          FragmentTransaction tx = FragmentManager.BeginTransaction();
//          tx.Add(Resource.Id.my_mapfragment_container, _myMapFragment);
//          tx.Commit();

                        // this line causes the error
            SetContentView (Resource.Layout.Main);
        }
    }
}

Main.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    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.MapFragment" />
</LinearLayout>

As said above, I have followed all steps of the tutorial; added Google Play Services, all required permissions and now getting this. Can anyone guide me as to what the problem is, because right now I'm tearing my hair out.

Thanks.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>