2013-12-18 81 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网站