-3

I want to display map using google API. I am able to generate API key using debug.keystore but it shows only grid with label google not map i have added MapView control in xml file . what am i missing?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="8" />
<permission
    android:name="com.example.maptest.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE" />
<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-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.maptest.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>
    <activity android:name="com.google.android.gms" />
    <uses-library android:name="com.google.android.maps" android:required="true" />

</application>

3 Answers3

0

I think you have not added a reference to the Google Play Services library to your project. See this guide Google Maps Android v2 for more further helps.

thuongle
  • 537
  • 6
  • 10
0

You are most likely missing some permission(s) in your Manifest, probably MAPS_RECEIVE or READ_GSERVICES. Check this related question.

Edit: Insert your API key just before the closing tag </application>:

<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="your_api_key"/>

Add the ACCESS_NETWORK_STATE permission:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Delete these lines:

<activity android:name="com.google.android.gms" />
<uses-library android:name="com.google.android.maps" android:required="true" />
Community
  • 1
  • 1
Nevermore
  • 995
  • 1
  • 9
  • 11
  • I have added all permissinon regarding this – user2289052 Apr 23 '13 at 04:08
  • But i am using MapView control in activity_main.xml file and also provide API key in MapView control , how can i insert API key in Manifest file . – user2289052 Apr 25 '13 at 04:08
  • @user2289052 You didn't _clearly_ state from the beginning which API _version_ you were trying to use. Setting your API key in your `com.google.android.maps.MapView` layout element was needed for - now deprecated - Maps Android **v1** API. For Maps Android API **v2**, which is using `com.google.android.gms.maps.MapView`, you only need to add your API (v2) key in your Manifest. Please follow the official [tutorial](https://developers.google.com/maps/documentation/android/) for API v2. Also, if this answer solves your problem, please accept it. – Nevermore Apr 25 '13 at 10:54
0

Please check whether you used Google android map in console and not Google Map. This might also be a problem. In addition to that another problem may be, you might have used map fragments. Use support Fragment in xml

android:name="com.google.android.gms.maps.SupportMapFragment"

GoogleMap gm;

gm = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
Shadow
  • 6,864
  • 6
  • 44
  • 93
  • using above code error is coming - The method getSupportFragmentManager() is undefined for the type MainActivity – user2289052 Apr 25 '13 at 07:49
  • @user2289052 That error means your `MainActivity` extends `Activity` rather than `FragmentActivity` from [Android Support Library](http://developer.android.com/tools/extras/support-library.html). – Nevermore Apr 25 '13 at 15:07