Hello, I am new to Xamarin and wanted to make a Google Map application with android. I followed step by step the tutorial found here: http://docs.xamarin.com/guides/android/platform_features/maps_and_location/maps/part_2_-_maps_api/
and I still end up with the same problem.
The application will not load. Actualy, it crash at the very moment I try to load the layout and I get this error:
Android.Views.InflateException: Binary XML file line #1: Error inflating class fragment
Here is the code
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Gms.Maps;
namespace NewMapApp
{
[Activity (Label = "NewMapApp", MainLauncher = true)]
public class MainActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// I GET MY ERROR HERE
SetContentView (Resource.Layout.Main);
}
}
}
This is my layout
<?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>
I have done some research and found someone that had pretty much the same problem: http://stackoverflow.com/questions/20381736/error-inflating-class-fragment-error-when-following-maps-api-tutorial
From what he said, his problem was that the application was missing some permissions and that he had to provide the Google Play Services version as a meta-data node. That didn't fix it for me though. Here is my android manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="NewMapApp.NewMapApp">
<uses-sdk />
<application android:label="NewMapApp" android:icon="@drawable/icon">
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>
Thanks a lot for your help!