在Android的谷歌地图V2问题 [英] Google map v2 issue in android

查看:132
本文介绍了在Android的谷歌地图V2问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好朋友我想在我的Andr​​oid设备上显示地图,所以我的code是如下

Hello friends i want to display map in my android device so my code is as below

的main.xml

 <fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="400dp"
    android:layout_height="400dp"
    />

的Manifest.xml

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

<!-- android:versionCode="2" -->
<!-- android:versionName="1.1" > -->

<uses-feature
    android:glEsVersion="0x00020000"
     android:required="true"/>

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

<uses-permission android:name="com.pakagename.example.permission.MAPS_RECEIVE" />

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

<supports-screens
    android:anyDensity="false"
    android:largeScreens="true"
    android:normalScreens="false"
    android:resizeable="false"
    android:smallScreens="false"
    android:xlargeScreens="true" />



<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" />

<application
    android:name=".RestaurantApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar" >
<meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="MY_API_KEY"
       />
    <activity
        android:name="pkg.android.rootways.restaurantapp.SplashActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape"
        android:windowSoftInputMode="adjustPan" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>


    <activity
        android:name="pkg.android.rootways.restaurantapp.ReviewActivity"
        android:screenOrientation="landscape"
        android:windowSoftInputMode="adjustPan" />


    </application>

 </manifest>

ReviewActivity.java

 public class ReviewActivity extends FragmentActivity implements LocationListener
 {
           @Override
 protected void onCreate(Bundle savedInstanceState) {
    GoogleMap myMap;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.res_review);

    initMap();
         }

public void initMap() {

    FragmentManager myFragmentManager = getSupportFragmentManager();
    SupportMapFragment mySupportMapFragment = (SupportMapFragment) myFragmentManager
    .findFragmentById(R.id.map);
    myMap = mySupportMapFragment.getMap();

    if (myMap != null)
    {
        System.out.println("MAp");
        myMap.setMyLocationEnabled(true);
        myMap.getUiSettings().setZoomControlsEnabled(true);
        myMap.getUiSettings().setCompassEnabled(true);
        myMap.getUiSettings().setMyLocationButtonEnabled(true);         
        myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    }

    else 
    {
        System.out.println("Null Value");
    }

   }

   }

当我运行ablove code它给了我错误,如

when i run ablove code it gave me error like

   12-02 16:23:55.544: E/AndroidRuntime(25420): Caused by:   java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does   not have the right value.  Expected 4030500 but found 0.  You must have the following   declaration within the <application> element:     <meta-data   android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.maps.internal.q.v(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.maps.internal.q.u(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.dynamic.a.a(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:284)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
    12-02 16:23:55.544: E/AndroidRuntime(25420):    

任何想法,我怎么能解决呢?

any idea how can i solve it?

推荐答案

我解决isssus

问题的地图API密钥我创建第一个API密钥,但它不是运行过程中出现,然后我为同一个pakagename第二API密钥所以r用于同一PAKAGE两个API密钥thaerefore它可能会发生冲突的关键,所以我做的解决方案就像我创建新PAKAGE名字,它是为我工作。

Issue in map api key i create first api key but it is not runnig then i create second api key for the same pakagename so there r two api key for same pakage thaerefore it may conflict the key so i make solution like i create new api key with new pakage name and it is working for me

这篇关于在Android的谷歌地图V2问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆