2014-10-05 75 views
-1

我的應用應該打開地圖。我已經包含了播放服務,實現了片段,並盡我所能做到了!不過,我在運行時遇到了「無法充氣」的錯誤。如何解決Android中的「無法膨脹」運行時錯誤?

我把我的清單文件,佈局文件和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

在你的片段中你有android:layout_below =「@ + id/acceleration」但是沒有組件的ID爲「acceleration」 – 2014-10-05 16:50:26

+0

我將它作爲textview實際上..但是由於我的客戶端版權問題,不能完全顯示在這裏..他堅持只顯示重要信息。 – user2857958 2014-10-05 19:04:26

+0

雖然真的很欣賞這個建議和努力。 – user2857958 2014-10-05 19:04:47

回答