元数据标记没有正确的价值 [英] The meta-data tag does not have right value

查看:119
本文介绍了元数据标记没有正确的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在android的新,我试图使用谷歌Play服务使用谷歌地图在我的应用程序。得到错误

i am newer in android , i am trying to use Google Maps in my application using google play services. getting errors

MapViewActivty:

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:

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的:

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)

我没有得到我在哪里错或丢失任何东西,如何删除,请帮我解决这个问题。感谢名单提前

I am not getting where I am wrong or missing anything and how to remove please help me in solving this issue. Thanx in advance

推荐答案

您的元数据标签是在&LT内部;活动> 标记。取出,并把它应用标签之后:

Your metadata tag is inside the < activity> tag. Remove and place it right after the application tag:

<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

这篇关于元数据标记没有正确的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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