Tibelius
Tibelius

Reputation: 63

Google API Key for Android Xamarin / C#. Map shows only a grey grid

So I've been trying to deal with this GreyGridOfDoom™ for the past two days with no results. I've read through tens of SO posts and skipped through at least a hundred Google search results about the topic.

The story so far:

So yeah. I have a gut feeling I have a bad API Key, but I really am not sure about that.

Heres my relevant code:

MapsActivity.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using Android.Support.V4.App;
    using Android.App;
    using Android.Content;
    using Android.OS;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.GoogleMaps;

    namespace IgluHarkka2
    {
        [Activity (Label = "MapsActivity", MainLauncher = true)]            
        public class MapsActivity : MapActivity
        {
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.Map);
                MapView mapView = (MapView) FindViewById(Resource.Id.mapView);
                mapView.SetBuiltInZoomControls (true);
            }

            protected override bool IsRouteDisplayed 
            {
                get {return false;}
            }
        }
    }

Map.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <com.google.android.maps.MapView
            android:id="@+id/mapView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:enabled="true"
            android:clickable="true"
            android:apiKey="XXXXXXXXXX" />
    </RelativeLayout>

AndroidManifest.xml

    <?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="IgluHarkka2.IgluHarkka2">
                <uses-sdk android:minSdkVersion="7" />
            <application android:label="IgluHarkka2">
                <uses-library android:name="com.google.android.maps" />  
            </application>
                <permission android:name="com.IgluHarkka2.IgluHarkka2.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>  

                <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" />
                <uses-feature android:glEsVersion="0x00020000" android:required="true" />
        </manifest>

Here I'm basically going ape about the problem and just spamming package names to see if that's the problem... Api Access screenshot

So if ANYONE can solve this problem I'd be pretty much the happiest person alive. I'll be refreshing this page a lot now since I have no solutions at the moment. I just can't figure this out :<

EDIT: More information:

Application output

    Forwarding debugger port 8897
    Forwarding console port 8898
    Detecting existing process
    [monodroid-gc] GREF GC Threshold: 1800
    Loaded assembly: IgluHarkka2.dll
    Loaded assembly: GooglePlayServicesLib.dll [External]
    Loaded assembly: Newtonsoft.Json.dll [External]
    Loaded assembly: Mono.Android.GoogleMaps.dll [External]
    Loaded assembly: Mono.Android.dll [External]
    [MonoDroid] Xamarin/Android Trial Mode Active
    [dalvikvm-heap] Grow heap (frag case) to 7.236MB for 441776-byte allocation
    [gralloc_goldfish] Emulator without GPU emulation detected.
    Loaded assembly: System.Core.dll [External]
    Loaded assembly: MonoDroidConstructors [External]
    [CursorWrapperInner] Cursor finalized without prior close()
    [CursorWrapperInner] Cursor finalized without prior close()
    [MapActivity] Handling network change notification:CONNECTED
    [MapActivity] Couldn't get connection factory client
    [System.err] IOException processing: 26
    [System.err] java.io.IOException: Server returned: 3
    [System.err]    at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
    [System.err]    at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
    [System.err]    at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
    [System.err]    at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
    [System.err]    at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
    [System.err]    at java.lang.Thread.run(Thread.java:856)

Screenshot of the emulator: Screenshot

Upvotes: 3

Views: 2350

Answers (1)

Tibelius
Tibelius

Reputation: 63

After changing from MapActivity to FragmentActivity I got past this error. Then I encountered another error, claiming that my project does not have/can't find Google Play Services. At this moment I started wondering, if the emulator was the reason, so I tried deploying the new version to a dev phone we have at the office and BOOM it works. Therefore I'd recommend everyone to try the Fragment way of creating the map if you are getting this error with no way to fix it.

Upvotes: 1

Related Questions