2
votes

I created a map using the following link http://developer.xamarin.com/guides/android/platform_features/maps_and_location/maps/part_2_-_maps_api/ i followed all the procedures mentioned in it but what am getting is a blank screen. My application Output shows the following log on executing the map activity.

Open Connection [REQUEST] DRD(41): 62|147 [REQUEST] Close [REQUEST] Error processing: com.google.maps.api.android.lib6.b.d@42a1cef8 not retrying [REQUEST] Retrying: com.google.maps.api.android.lib6.c.au@429ced70

Can anyone please tell me why this is happening.

3
Usually it is a key issue. Did you enable access through google apis console? Using correct key? Etc. You might also get more info if you look at Log from your device (not just output window).Miha Markic
@MihaMarkic i enabled the access through google apis console and created the key from there itself.aps87

3 Answers

3
votes

As @Miha mentioned this is keys related.

At present you will not be getting any map tiles displayed on the map.

To get the example to work there are several things that you need to do.

1) Obtain your Signing Key Fingerprint (SHA1) for your machine.

If you haven't already created your SHA1 key for your machine you will need to do this first. The link here describes how to generate this using the command console.

You will get a SHA1 key fingerprint as a result of this.

2) Obtain the package name from the project you are working on.

This can be located by looking at the Android project properties under the Android Manifest tab. You will then see a text-box for the Package name field.

3) In Google Developer Console you will need to create an Application should you not already have one, and Create A New Android key (This is located under APIs & auth \ Credentials).

On the screen that will pop-up you will be able to enter in the SHA1 key and Package Name that you have previously captured in the format {SHA1};{Package Name}.

This will then return to you the API key that you will use in the next step:-

4) In the Android Project, look at the source for AndroidManifest.xml. You will see the following:-

<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="{some api key}" />      

Enter you API key in that you have previously captured.

5) In the Google Developer Console, for the project, you also have to remember that you have to enable Google Maps Android API v2 and also Google Play Android Developer API. You can find these under APIs & auth \ APIs

You should then, finally, be able to run the demo.

Update 1:-

Add the uses-permission for MAPS_RECEIVE as @leoneboaventura mentioned also, so something like the following:-

<uses-permission android:name="{your-package-name}.permission.MAPS_RECEIVE" />
2
votes

If you are unable to view the map after deploying a Release apk, follow this Video.. https://www.youtube.com/watch?v=xLJ0jDFdUZ0

As it says :

  1. Create a KeyStore from Visual Stuido.

a. Put project config mode to Release.

b. Clean and Build your Android project.

c. Right click your Android project and select Archive (Before that specify the version code and version name in your manifest or in properties).

d. Once the archive is completed, click on Distribute.

e. Select AdHoc channel.

f. Create a new Signing Identity with Alias, Password and other info.

g. This signing key creates a KeyStore file in location : C:\Users\[UserName]\AppData\Local\Xamarin\Mono for Android\Keystore\[Alias]\[Alias].keystore Note : [Alias] is the name you defined when creating the KeyStore file

  1. Open your cmd. cd to C:\Program Files\Java\jdk1.8.0_131\bin

  2. Execute : keytool -list -v -keystore "C:\Users\[UserName]\AppData\Local\Xamarin\Mono for Android\Keystore\[Alias]\[Alias].keystore" -alias [Alias]

  3. You will get the output with MD5, SHA1, SHA256... Copy the SHA1 key.

  4. Go to https://console.developers.google.com . Select your project you created for Android API key.

  5. Click on credentials and select your API key.

  6. Add new Package name and finger print with your project's package name and SHA1 key you copied. Note : Project's package name defined on Android Project's manifest and properties.

  7. Wait for like 5 mins to take the changes to affect. Afterwards you can again archive and get a new APK. Install on your android device and see. You will now be able to see the map.

NOTE :: I am referring to Xamarin, Visual Studio 2017

1
votes

I just figured out what was wrong in my case. Probably because of Java naming rules, you have to name your package with the first letter in lowercase. Visual Studio names our packages following C# naming rules, which spells the first letters capitalized.

So, check if this issue isn't the same causing your map to don't open by doing the following:

1) Make sure your package name starts with small letter.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="mypackage.android" android:versionCode="1" android:versionName="1.0">

Make sure your package is named mypackage.android not MyPackage.android.

2) Make sure your package name in the following two permissions matches the manifest package name spelling:

<uses-permission android:name="mypackage.android.permission.MAPS_RECEIVE" />
<permission android:name="mypackage.android.permission.MAPS_RECEIVE" android:protectionLevel="signature" />

3) Check if you APIKey is been generated to the same package name: {your SHA1 certificate fingerprint}:mypackage.android