Ryan Langton
Ryan Langton

Reputation: 6160

Google Maps Api v2 Xamarin blank screen

I'm unable to get google maps api v2 to display anything more than a blank screen in my Android Xamarin application.

In logcat, I get the following error.

07-08 16:08:12.192: E/Google Maps Android API(28625): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

This makes me believe it is a problem with my API key. I don't know what I'm missing though. Here is my AndroidManifest.xml.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="2" android:versionName="2.0.0.0" package="com.deg.blubcnmobl.droid">
    <uses-sdk android:targetSdkVersion="12" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
    <uses-permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE" />
    <application android:icon="@drawable/logo" android:debuggable="true" android:enabled="true" android:persistent="false" android:allowClearUserData="true" android:theme="@android:style/Theme.Black.NoTitleBar">
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_KEY" />
    </application>
</manifest>

Here is my activity axml:

<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" />
</LinearLayout>

I have Google Maps Api V2 Android turned on in API settings.

Imgur

Here is the page where I created the API key.

Imgur

Upvotes: 0

Views: 4415

Answers (4)

adelriosantiago
adelriosantiago

Reputation: 8124

Please check this post: Google Map Android Api V2 Sample Code not working, if you are completely sure you did the right steps and still see the blank screen then follow the second answer, the authentication gets cached somewhere, try to uninstall the application manually (just like you do with a normal application) then "Run" again the project.

Upvotes: 0

Emmanuel
Emmanuel

Reputation: 13223

Make sure you add these permissions to the manifest

<permission
    android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE"/>

Upvotes: 3

ddewaele
ddewaele

Reputation: 22603

You seem to be missing a number of permissions in your manifest.

  • Sample manifest for Maps V2 capable of running on API level 8 and upwards

https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/AndroidManifest.xml

  • Sample layout for Maps V2 capable of running on API level 8 and upwards

https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/res/layout/activity_main.xml

  • Sample activity for Maps V2 capable of running on API level 8 and upwards

https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/src/com/example/googlemaps/v2/skeleton/api8/MainActivity.java

You can clone the git repository above and try the complete GoogleMapsV2SkeletonV8 application.

Upvotes: 0

Related Questions