【发布时间】:2014-04-11 11:10:23
【问题描述】:
我正在尝试使用谷歌地图,所以从以下链接下载了谷歌地图项目
我已经将 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 key mainfeast,把我的activity扩展到fragmentActivity
请帮帮我。
我的 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>
【问题讨论】:
-
发布您的 manifest.xml 文件
-
你甚至没有尝试阅读日志......再次阅读 logcat 那里有解决方案
-
我已经尝试了日志错误但同样的问题。
-
i already try with log error but same issue.那你做了什么? -
我尝试了日志错误但同样的错误,也尝试了新的 api 密钥但错误仍然相同
标签: android google-maps android-fragments android-fragmentactivity google-maps-api-2