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.
Here is the page where I created the API key.
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"/>
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.
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.
I have given an answer of it at https://forums.xamarin.com/discussion/26058/google-map-is-showing-a-blank-screen-in-android
Related
Though I know this has been a persistent and addressed issue, everyone's problem seems to be solved a different way every time. I have been trying to get my map to show all day but to no avail. I had a project which had a map in it, so what I migrated that project to another location and set up Google Play Services in that project. I got everything to work except for the map to show. I have the library as i am able to use LatLng but the map always fails to load. I have generated new keys, deleted and re added the key, and deleted and re added the debug keystore. I have also updated the api console to ensure everything lined up but my map still doesnt show. I have Google Map for Android Api enabled in the console. And my package name is correct also. I have ran a clean rebuild and uninstalled the app to see if it works but it still doesnt load.
NOTE: I have also tried using SupportMapFragment instead.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.wallfly"
android:largeHeap="true">
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Actionbarstyle">
<activity
android:name="com.android.wallfly.MyActivity"
android:label="#string/app_name" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="(Actual API Key)" />
</application>
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.android.wallfly.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.android.wallfly.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- these grant the app the ability to access location. coarse is wifi and cellular, fine is gps -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I have added an image to show that my package name lines up. Also i copied and pasted the SHA1 fingerprint so I am sure that it does line up also.
For those who may face a similar problem, my google play service was outdated. So I had to change the build.gradle the current version of google play service.
When I try to debug my project I got this error using debug certificate
I already ensure that my package name and SHA-1 corresponds to my api key
Here's my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.example">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />
<!-- Google Maps for Android v2 requires OpenGL ES v2 -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<!-- We need to be able to download map tiles and access Google Play Services-->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Allow the application to access Google web-based services. -->
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Google Maps for Android v2 will cache map tiles on external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Google Maps for Android v2 needs this permission so that it may check the connection state as it must download data -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to receive remote notifications from Google Play Services -->
<!-- Notice here that we have the package name of our application as a prefix on the permissions. -->
<uses-permission android:name="com.example.permission.MAPS_RECEIVE" />
<permission android:name="com.example.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<!-- These are optional, but recommended. They will allow Maps to use the My Location provider. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application android:label="map" android:icon="#drawable/Icon">
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="map_key" />
</application>
</manifest>
Here's my API KEY
Here's my SHA-1 certificate
I got my SHA-1 using eclipse
By the way I'am using real device in debugging my project, c#, visual studio 2012 and xamarin.android. It only displays white screen with google logo and zoom in and out button. What's wrong with my debug certificate?
If the key is new ( has just been created in Google APIs Console ) it will take some time for it to be available to Google Maps.
Don't worry everything is declared OK, it just takes some time.
Edit : By what is written in the log looks like you have to add the fingerprint for your debug key store : D9595..
Just add a new line in Google APIs console with that fingerprint . Your debug keystore is found at C:\Users\.android\debug.keystore and the default password is : android
I got this following error when loading google map android api v2
1. Authorization failure.
2. Ensure that the following correspond to what is in the API Console: Package Name: com.example, API Key: AIzaSyDjm0K-ucpO5mDCPPnQ4CzVpdguqM714uo, Certificate Fingerprint: D9595FF0F329A6BBAC466C63284F83D17859894B
3. Failed to contact Google servers. Another attempt will be made when connectivity is established.
4. Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
5. Failed to find provider info for com.google.android.gsf.gservices
Here's my source code:
My AndroidManifest source code
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.example">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />
<application android:label="map" android:icon="#drawable/Icon">
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyDjm0K-ucpO5mDCPPnQ4CzVpdguqM714uo" />
</application>
<permission android:name="com.example.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>
My Main.axml source code
Main.axml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
My Activity1 source code
Activity1.cs
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace map
{
[Activity(Label = "map", MainLauncher = true, Icon = "#drawable/icon")]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
}
}
}
By the way I'am using API Level 15 emulator.
Here's my api key
Although it is not recommended, it is possible to setup the emulator to support the Android Maps API v2. The emulator must be configured to target the Google API Level 17 (Android 4.2.2) or higher.
Yours is set to API Level 15...
Also you need to set your project's target API and min API Level to 17 (it is currently 14) if you want to load Google map in Emulator.
Read the prerequisites here:
http://docs.xamarin.com/Guides/Android/Platform_Features/Maps_and_Location/Part_2_-_Maps_API/#Configuring_Maps_API_Prerequisites
Write the following feature to your menifest
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
Improve your xml
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.**SupportMapFragment**" />
I found the answer to my problem. My SHA1 fingerprint doesnt match the certificate fingerprint I use ( in my error message). Now my application loads the android google map properly.
The error:
08-15 12:59:17.435: E/Google Maps Android API(14665): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
The Google Console:
The manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cefetmgrdctcc.sgtp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.cefetmgrdctcc.sgtp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.cefetmgrdctcc.sgtp.permission.MAPS_RECEIVE"/>
<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="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<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"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Hidden key"/>
<activity
android:name="com.cefetmgrdctcc.sgtp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The layout of the map control:
<fragment
android:id="#+id/googlemap"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
I've imported the Google Play Services into my project and marked on the Google API Console Services list "Google Maps API v2", "Google Maps API v3" and "Google Maps Android API v2", however it seems my Map Fragment is still not being able to authenticate.
Map Fragment is just a blank grey square on the middle of the screen, any ideas why is this happening?
Hi I was just having this exact same problem. I tried everything the docs said but nothing seemed to work.
The only thing that worked for me was uninstalling and reinstalling my application (not even rebooting worked) because apparently if you make one mistake on the configuration the system caches the failed authentication and your maps won't work even after fixing your configuration.
So try following the docs and guides on configuring Google Maps Api on Android but every time you change something on your configuration uninstall and reinstall.
If you are running application on a device,experiencing the same issue and had no luck any other solutions.
make sure the installed google-play services is the latest one.
make sure the device date and time is correct as well
http://www.techkhoji.com/no-connection-retry-google-play-store/
Google Play Services sync with their master servers to send and
receive data, to do this your device time and date should be correctly
set
Check if other applications depend on google-play services such as Play Store are working.If they are having trouble with connecting to servers ("NO CONNECTION, RETRY") even when the internet connection is available one of the above points could be the solution.
I regenerated API key and updated in google console, its working fine
Application just displays a plain skin colored screen instead of a mapView.
I have tried followings :
I have followed all the steps from this docs.
I have enabled Google Maps Android API v2 in Google API console.
I have generated an API key for android. Also tried creating several times. Even on different machine.
I have added Google play services to my project.
I tried setting Custom debug keystore to Default debug keystore.
My AVD target is set to Google APIs level 17.
Manifest.xml file :
<permission
android:name="com.objectlounge.ridesharebuddy.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.objectlounge.ridesharebuddy.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API_KEY"/>
<uses-library android:name="com.google.android.maps"/>
My activity and layout files are same as in this docs.
I use emulator. I am not sure if android mapView v2 is supported in emulator.
Any idea what is the problem?
Make sure your activity extends a FragmentActivity instead of Activity.
And replace you xml layout fragment with the following one:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />