2013-12-18 165 views
0

我不知道工作,怎麼我在任我的清單,活動或XML做錯了加載地圖版本2,谷歌地圖版本2不片段

我找到了多個例外,如果你看到我的簡潔的logcat ,

E/AndroidRuntime(16522): FATAL EXCEPTION: main 
E/AndroidRuntime(16522): java.lang.RuntimeException: Unable to start activityComponentInfo{com.production.MyApp/com.project.MyApp.AddEvent.AddEventMapActivity}:  
android.view.InflateException: Binary XML file line #7: Error inflating class fragment 
E/AndroidRuntime(16522): Caused by: android.view.InflateException: Binary XML file line  #7: Error inflating class fragment 
E/AndroidRuntime(16522): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) 
E/AndroidRuntime(16522): at android.app.Activity.setContentView(Activity.java:1892) 
E/AndroidRuntime(16522): at com.project.MyApp.AddEvent.AddEventMapActivity.onCreate(AddEventMapActivity.java:20) 
E/AndroidRuntime(16522): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 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" /> 
E/AndroidRuntime(16522): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source) 
E/AndroidRuntime(16522): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source) 
E/AndroidRuntime(16522): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) 
E/AndroidRuntime(16522): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279) 

而明顯的模樣,

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.production.MyApp" 
android:versionCode="3" 
android:versionName="1.0" > 

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

<uses-permission android:name="android.permission.INTERNET" /> 

<permission 
    android:name=" com.production.MyApp.permission.MAPS_RECEIVE" 
    android:protectionLevel="signature" /> 

<uses-permission android:name=" com.production.MyApp.permission.MAPS_RECEIVE" /> 
<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" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

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

<application 
    android:name="com.project.MyApp.MyApplication" 
    android:enabled="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Light.NoTitleBar" > 

    <meta-data 
     android:name="com.google.android.maps.v2.API_KEY" 
     android:value="no issue with api_key here" /> 

和XML,

雖然我延長FragmentActivity

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

    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 = ((SupportMapFragment) getSupportFragmentManager().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(); 
     } 
    } 
} 

回答

1

您需要添加下面的清單文件

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

將這個在你清單的最後,你的地圖API密鑰的元數據後,標籤。

退房HERE

這是從最後一次修訂13更新的Google Play服務增添了新的要求。

+0

你是一流的:) –

+0

日Thnx ....... :) – GrIsHu

+0

@GrIsHu太好了.. !! – Piyush

0

您需要添加可在logcat的錯誤味精被發現在您的清單

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

</application> 

該信息如下。

而且還google play services網站