Search code examples
androidgoogle-mapsgoogle-maps-api-2

google map is not displayed


I am developing small application in android.

I already got my google maps api key.

But when i start my application in device and starts the activity that contains the google map only activity appears and zoom controls are displayed but no map displayed here is my code.

This is my layout code.

<?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"
      android:name="com.google.android.gms.maps.MapFragment"/>

This is my manifeast file code.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.project.kamani.nearby"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />


<uses-permission android:name="com.project.kamani.nearby.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.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
<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="here is used my api key but not written here"/>

    <activity
        android:name="com.project.kamani.nearby.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>

I already registered my application at google api console.

My java file only contains

setContentView(R.layout.activity_main);

line.

It also does not show any error can any body tell me why this is happening?


Solution

  • If you are deploying your application for debugging purposes (for example via USB cable) you should create SH-1 for your debug keystore otherwise you should use your own keystore (in case if you deploy application to the Google Play Market for example). For debuging purposes, create SH1 like shown below:

    C:\<path-to-jdk-dir>\bin\keytool.exe -list -alias androiddebugkey -keystore "C:\users\<user-name>\.android\debug.keystore" -storepass android -keypass android
    

    Please notice that storepass and keypass for debugging purposes is android. Then register your app with the Google APIs Console using generated SH-1 fingerprint.