我正在尝试谷歌地图,所以从以下链接下载谷歌地图项目
我已经将API密钥放在Manifest中了。
但它会出现以下错误
java.lang.RuntimeException: Unable to start activity ComponentInfo{in.wptrafficanalyzer.locationgeocodingapiv2/in.wptrafficanalyzer.locationgeoc
odingapiv2.MainActivity}: android.view.InflateException: Binary XML file line #24:Error inflating class fragment
04-11 16:09:55.679: E/AndroidRuntime(3510): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-11 16:09:55.679: E/AndroidRuntime(3510):at android.app.ActivityThread.performLaunchActivity (Activity Thread .java: 1651)
04-11 16:09:55.679: E/AndroidRuntime(3510): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-11 16:09:55.679: E/AndroidRuntime(3510): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-11 16:09:55.679: E/AndroidRuntime(3510):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-11 16:09:55.679: E/AndroidRuntime(3510): Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
04-11 16:09:55.679: E/AndroidRuntime(3510): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
04-11 16:09:55.679: E/AndroidRuntime(3510): at android.app.Activity.setContentView(Activity.java:1657)
04-11 16:09:55.679: E/AndroidRuntime(3510): at in.wptrafficanalyzer.locationgeocodingapiv2.MainActivity.onCreate(MainActivity.java:46)
04-11 16:09:55.679: E/AndroidRuntime(3510): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 16:09:55.679: E/AndroidRuntime(3510): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4242000 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" />
04-11 16:09:55.679: E/AndroidRuntime(3510): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
04-11 16:09:55.679: E/AndroidRuntime(3510): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
我已经提供了API密钥mainfeast并将我的活动扩展到fragmentActivity
Plz帮助我。
我的AndroidMainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.wptrafficanalyzer.locationgeocodingapiv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="in.wptrafficanalyzer.locationgeocodingapiv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="in.wptrafficanalyzer.locationgeocodingapiv2.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="package.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY API keY" />
</application>
答案 0 :(得分:2)
尝试在<meta-data>
文件中的<application>
标记下添加manifest.xml
代码,例如
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
让你的manifest.xml
像这样
....<application>
..............
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Key" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
并就此提供反馈