android – 元数据标记没有正确的值

我是 android的新手,我试图在我的应用程序中使用谷歌地图使用谷歌播放服务获取错误.

MapViewActivty:

public class MapsViewActivity extends FragmentActivity {
// Google Map
private GoogleMap googleMap;

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

    try {
        // Loading map
        initilizeMap();

    } catch (Exception e) {
        e.printstacktrace();
    }

}

/**
 * function to load map. If map is not created it will create it for you
 * */
private void initilizeMap() {
    if (googleMap == null) {
        googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                R.id.map)).getMap();

        // check if map is created successfully or not
        if (googleMap == null) {
            Toast.makeText(getApplicationContext(),"Sorry! unable to create maps",Toast.LENGTH_SHORT)
                    .show();
        }
    }

maps.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

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

manifest.xml文件

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

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

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

<uses-permission android:name="com.example.careandcure.permission.MAPS_RECEIVE" />
<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_COARSE_LOCATION" />
<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-feature
    android:glEsversion="0x00020000"
    android:required="true" />

<application
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.careandcure.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.careandcure.MapsViewActivity" >
    </activity>
    <activity
        android:name="com.example.careandcure.MySearchAbleActivity"
        android:launchMode="singletop" >
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>
        <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="AIzaSyBOhdOOMI_ZMYlvSyi7DVeRe_bo9ckxehM" />
        <Meta-data
            android:name="android.app.searchable"
            android:resource="@layout/searchable" />
    </activity>
    <!-- declare the default searchable Activity for the whole app -->
    <Meta-data
        android:name="android.app.default_searchable"
        android:value=".MySearchAbleActivity" />
 </application>

 </manifest>

并收到以下错误

08-06 11:34:28.256: E/AndroidRuntime(5932): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.careandcure/com.example.careandcure.MapsViewActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
08-06 11:34:28.256: E/AndroidRuntime(5932): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
08-06 11:34:28.256: E/AndroidRuntime(5932):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.example.careandcure.MapsViewActivity.onCreate(MapsViewActivity.java:17)
08-06 11:34:28.256: E/AndroidRuntime(5932): Caused by: java.lang.IllegalStateException: The Meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 5089000 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" />
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.common.GooglePlayServicesUtil.A(UnkNown Source)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(UnkNown Source)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.maps.internal.u.I(UnkNown Source)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.maps.internal.u.H(UnkNown Source)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.maps.MapsInitializer.initialize(UnkNown Source)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.maps.SupportMapFragment$b.a(UnkNown Source)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.dynamic.a.a(UnkNown Source)
08-06 11:34:28.256: E/AndroidRuntime(5932):     at com.google.android.gms.dynamic.a.onInflate(UnkNown Source)

我没有得到我错在哪里或遗失任何东西以及如何删除请帮助我解决这个问题.提前致谢.

解决方法

您的元数据标签位于<活性GT;标签.删除并将其放在应用程序标记之后:
<application
android:allowBackup="true"
android:icon="@drawable/logo"
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="AIzaSyBOhdOOMI_ZMYlvSyi7DVeRe_bo9ckxehM" />
    <Meta-data
        android:name="android.app.searchable"
        android:resource="@layout/searchable" />
<activity>//not activity tags

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...