我的应用程序应该打开一张地图。我已经包括了游戏服务,实现了片段,并尽我所能!但是我得到了一个"不能膨胀"运行时出现错误。
我正在处理我的清单文件,布局文件和logcat错误。
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.xyz"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="xyz.xyz.permission.MAPS_RECEIVE"
android:protectionLevel="signature"
/>
<uses-permission android:name="xyz.xyz.permission.MAPS_RECEIVE" />
<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" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name="Home"
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=".HelloGoogleMaps" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"/>
<uses-library android:name="com.google.android.maps"/>
</application>
布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="xyz.xyz.Home" >
<fragment
android:id="@+id/mapView"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="@+id/acceleration"
android:layout_marginTop="20dp"
android:apiKey="GoogleAPIKEY//I Added a Key, I just do not feel comfortable to display it"
android:clickable="true"
android:enabled="true" />
</RelativeLayout>
logcat的
01-05 04:33:18.003: E/AndroidRuntime(9303): FATAL EXCEPTION: main
01-05 04:33:18.003: E/AndroidRuntime(9303): java.lang.RuntimeException: Unable to start activity ComponentInfo{xyz.xyz/xyz.xyz.Home}: android.view.InflateException: Binary XML file line #20: Error inflating class fragment
01-05 04:33:18.003: E/AndroidRuntime(9303): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. 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" />
01-05 04:33:18.003: E/AndroidRuntime(9303): at com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
01-05 04:33:18.003: E/AndroidRuntime(9303): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
还有更多但看起来很重要。此外,它添加为元数据的内容已被添加,它仍然会产生异常。
答案 0 :(得分:0)
您的Android SDK中是否有 Google Play服务库?如果没有,请检查http://developer.android.com/google/play-services/setup.html。 如果您要离线下载 Google Play服务,请转到http://venomvendor.blogspot.com/2012/03/android-sdk-extras-by-google-inc.html。