Search code examples
xamaringoogle-maps-api-2mvvmcross

MvvmCross with a MapFragment


I am unable to create an activity using the google map v2 fragment. Custom fragments work fine, this is only a problem with a MapFragment.

<?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
    class="com.google.android.gms.maps.SupportMapFragment"
    android:id="@+id/mapfragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Here is the error:

mvx:Diagnostic: 36.27 Showing ViewModel TruckWashMapViewModel
[0:] mvx:Diagnostic: 36.27 Showing ViewModel TruckWashMapViewModel
07-03 17:24:51.184 I/mono-stdout(16230): mvx:Diagnostic: 36.27 Showing ViewModel TruckWashMapViewModel
07-03 17:24:51.214 I/Choreographer(16230): Skipped 297 frames!  The application may be doing too much work on its main thread.
Resolved pending breakpoint at 'c:\_Application\BLUBCNMOBL\src\BLUBCNMOBL.Droid\Views\TruckWashMapView.cs:17,1' to OnCreate [0x00001].
[0:] mvx:Diagnostic: 40.71 Loading new ViewModel from Intent with Extras
[0:] mvx:Diagnostic: 40.71 Loading new ViewModel from Intent with Extras
07-03 17:24:55.629 I/mono-stdout(16230): mvx:Diagnostic: 40.71 Loading new ViewModel from Intent with Extras
[0:] 
MvxBind:Error: 42.60 View type not found - fragment
[0:] MvxBind:Error: 42.60 View type not found - fragment
07-03 17:24:57.511 I/mono-stdout(16230): MvxBind:Error: 42.60 View type not found - fragment

Looking through the further through the stack trace, it looks like the is an error with the API key. But I do have my API key in the AndroidManifest.xml.

07-05 14:55:02.231 I/MonoDroid(31877): Caused by: java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml

AndroidManifest.xml

<application android:icon="@drawable/logo"
                 android:debuggable="true"
                 android:enabled="true"
                 android:persistent="false"
                 android:allowClearUserData="true">
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="xxx" />

Solution

  • I should have posted my entire AndroidManifest.xml. The problem was that I had 2 Application nodes within the manifest.