Android映射v2 Api所需的元数据

时间:2015-01-21 09:31:09

标签: android google-maps-android-api-2

运行使用Google Maps API v2的应用时遇到问题:

  

填充类片段时出错。引起:您的应用程序的AndroidManifest.xml中所需的元数据标记不存在

我的AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="19" />

     <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.INTERNET"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CALL_PHONE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.My" >
        <activity
            android:name="com.my.package.SplashActivity"
            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.my.package.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.my.package.MAINMENU" />

                <category android:name="android.intent.category.DEFAULT"
                  android:screenOrientation="portrait" />
            </intent-filter>
        </activity>

         <activity
                android:name="com.my.package.MoverseFragment"
                android:theme="@style/Theme.My" 
                android:screenOrientation="portrait"
                 >
         </activity>


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

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

    </application>
</manifest>

如果有帮助,这是我的xml,错误在片段的行中:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MoverseFragment" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

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

    </LinearLayout>

</LinearLayout>

2 个答案:

答案 0 :(得分:2)

缺少此代码插入清单

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

答案 1 :(得分:-1)

您可以插入:

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

它告诉应用正在使用的Google Play版本

编辑:作为参考,这是我的一个应用程序的工作清单:

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

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/maps_api_key" />

    <!-- activities -->

</application>
</manifest>

也许是OpenGL的一个?