2014-02-20 157 views
0

我想實現簡單的谷歌谷歌MapV2誤差圖譜例如我搜索有關,但沒有明確的解決方案 清單:有關meta標籤

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

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

<permission 
    android:name="com.syntel.mapexample.permission.MAPS_RECEIVE" 
    android:protectionLevel="signature" /> 

<uses-permission android:name="com.syntel.mapexample.permission.MAPS_RECEIVE" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

<!-- Required to show current location --> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

<!-- Required OpenGL ES 2.0. for Maps V2 --> 
<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.syntel.mapexample.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> 

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

    </manifest> 

XML:

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

    </RelativeLayout> 

我我試圖實現簡單的地圖示例查看地圖,但得到錯誤

Logcat詳細信息:

02-20 10:53:15.706: E/AndroidRuntime(23385): java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.syntel.mapexample/com.syntel.mapexample.MainActivity}: android.view.InflateException: Binary 
XML file line #6: Error inflating class fragment 

02-20 10:53:15.706: E/AndroidRuntime(23385): at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 
02-20 10:53:15.706: E/AndroidRuntime(23385): at 
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
02-20 10:53:15.706: E/AndroidRuntime(23385): at 
    android.app.ActivityThread.access$600(ActivityThread.java:141) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): at 
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): at android.os.Handler.dispatchMessage(Handler.java:99) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): at android.os.Looper.loop(Looper.java:137) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): at 
    android.app.ActivityThread.main(ActivityThread.java:5041) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): at java.lang.reflect.Method.invokeNative(Native Method) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): at java.lang.reflect.Method.invoke(Method.java:511) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): at 
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
    02-20 10:53:15.706: E/AndroidRuntime(23385):  at 
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
    02-20 10:53:15.706: E/AndroidRuntime(23385):  at dalvik.system.NativeStart.main(Native Method) 
    02-20 10:53:15.706: E/AndroidRuntime(23385): Caused by: android.view.InflateException: Binary XML file 
    line #6: Error inflating class fragment 

    02-20 10:53:15.706: E/AndroidRuntime(23385): 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" /> 
+0

還添加該元數據在menifest:<元數據 機器人:名字=」 com.google.android.gms.version「 android:value =」@ integer/google_play_services_version「/> – Vijju

回答

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

添加它低於或高於谷歌地圖API密鑰

1

添加谷歌Play服務版本,您的應用程序的清單

編輯您的應用程序的AndroidManifest.xml文件,並添加 在元素之後聲明。這嵌入了該應用程序編譯的Google Play服務版本 。

您需要添加<meta-data><application>代碼到你的AndroidManifest.xml

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

這是因爲latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml