0

I've found different topic about this, but neither got me the maps working in my activity. I've followed the guide provided by google about using maps from google play service:

  1. I've download and added to my libraries google play services
  2. I've created a new activity based on the Service > Map Activity template
  3. I've followed the instructions in google_maps_api.xml to get the api key
  4. Built and run the application on my device
  5. Realized I missed something I've added permissions suggested from other threads in the manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.labinfo.hotels.core" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="net.labinfo.hotels.core.permission.MAPS_RECEIVE"/>
    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <uses-permission android:name="net.labinfo.hotels.core.permission.C2D_MESSAGE" />
    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <application
        android:allowBackup="true"
        android:largeHeap="true"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.analytics.globalConfigResource"
            android:resource="@xml/global_tracker" />
      
      .....
      
        </activity>

        <activity
            android:name=".components.activities.avis.AvisMappaActivity"
            android:label="@string/title_activity_avis_mappa" >
        </activity>

        <uses-library android:name="com.google.android.maps"/>
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/google_maps_key" />

    </application>

</manifest>

Still the result is the activity showing only the google logo in the corner and no sign of errors or notifications from logcat. Am I missing something? I saw that during the google console generation of the api key it showed to me a SHA key, but I've never used it.

Hope somebody can help me out about this

Pievis
  • 1,954
  • 1
  • 22
  • 42

4 Answers4

2

When you cant see map and also no error that means it is a problem with API key. You need to get an API key from google to use Google Map perfectly. To get the API key you need to follow some steps and in one of those steps you need to use the SHA fingerprint key. However the link below shows you the steps.

https://developer.xamarin.com/guides/android/platform_features/maps_and_location/maps/obtaining_a_google_maps_api_key/

Zahan Safallwa
  • 3,880
  • 2
  • 25
  • 32
  • I've used the url provided in my google_maps_api.xml to generate the key, I think it's a short way to do the same, but I'll check again and make a new key. – Pievis Sep 29 '15 at 13:08
1

I've solved it. As all of you suggested it was the API key, in particular permissions related to that key.

My problem was the package name, since I used an app with different module, the package name sent to the server was different than the one used to create the key automatically. So I've fixed the problem adding to permission another package name with the same SHA1 key.

For all future readers, I want you to note that I had no error shown until I switched from SupportMapFragment to MapFragment, so I suggest to do so for debugging.

Thanks to anyone helping, cheers.

Pievis
  • 1,954
  • 1
  • 22
  • 42
0

When map is shown blank the reason use to be a problem with your API key. I would check that you generate the API Key correctly.

juanmeanwhile
  • 2,594
  • 2
  • 24
  • 26
  • 1
    I've done it 3 times already, but I've always the same result. Think is that in the procedure they don't give you the permission to add into the manifest, so I don't know if they are all ok. – Pievis Sep 29 '15 at 13:10
0

Add this line in the application tag of the manifest

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>

also make sure that you correctly generate the api key. visit this link How to generate the api key

Tabish Hussain
  • 852
  • 5
  • 13
  • I've that already setted, I've also checked again all the procedure to generate the api key, but no luck. – Pievis Sep 29 '15 at 13:05