我是第一次使用android map V2。我在AndroidManifest.xml文件中添加了所有“需要权限”,并且还添加了我的地图密钥。我当时导入了外部地图库,并且还在模拟器中安装了Google Play服务。我的应用程序无法加载MAPFRAGMENT。
当我运行Appliction时,在MAP_FRAGMENT中出现错误,我的activity_mail.xml文件为
<?xml version="1.0" en`enter code here`coding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
我的AndroidManifest.xml文件是
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prakash.googlemapall"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<permission
android:name="com.praakash.googlemapall.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.praakash.googlemapall.permission.MAPS_RECEIVE" />
<uses-permission
android:name="android.permission.INTERNET"
android:required="true" />
<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" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
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="here I put my key" />
<activity
android:name="com.prakash.googlemapall.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>
</application>
</manifest>
当我运行此应用程序时,它给出的错误是**
05-07 11:15:04.960: E/AndroidRuntime(22116): FATAL EXCEPTION: main
05-07 11:15:04.960: E/AndroidRuntime(22116): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.prakash.googlemapall/com.prakash.googlemapall.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
05-07 11:15:04.960: E/AndroidRuntime(22116): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 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" />
**
只需将清单文件中的元数据标签替换为以下标签即可。
<meta-data android:name="com.google.android.gms.version"
android:value="4323000" />
一次检查google-play-services库清单文件中的版本代码。
如果它在xml文件中包含此行
android:versionCode="4242000"
然后将其更改为
android:versionCode="4323000"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句