简体   繁体   中英

showing google map v2

Am facing a Fatal exception on running google map v2 , i did import google-play-service-lib and make an Api from google, and that the mainfest am using :

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


<permission
        android:name="com.example.getLocation.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>

<uses-permission android:name="com.example.getlocation.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"/>
<!-- 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-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />


<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" >
        <activity
            android:name="com.example.getlocation.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.example.getlocation.map"
                              android:screenOrientation="portrait"
            ></activity>    
    <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="AIzaSyB7rXLp7f3cnZ0sdjqQnCQiPbiPpkNVmPc"/>
    </application>

</manifest>

and the map layout xml is :

 <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/the_map"

        android:name="com.google.android.gms.maps.SupportMapFragment "
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

and here is the class activity :

package com.example.getlocation;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class map extends FragmentActivity  {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);
    }
 }

and the phone am running on version is 2.3.6 ,

Try different code

link: http://www.vogella.com/articles/AndroidGoogleMaps/article.html

Here completely describe about googlemap one thing you always remeber that your googlemap cannot display on emulator it will run on real device but you should first test it on your emulator if no error occur then test it on real phone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM