5月のアプリにGoogleマップを追加しようとしているので、APIキーを取得しました。残念ながら、メタデータタグを使用してmanifest.xmlにAPIキーを挿入すると、以下に示すように、コンパイル時に別のメタデータタグが自動的に挿入されました。これで、以下のエラーが発生します。最悪の場合、それらのいずれかまたは両方を削除しても、コンパイル時に両方のタグが自動的に生成され、エラーがスローされます。
何か助けは?
エラー
Java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exampl.t_collect/com.exampl.t_collect.activity.MapActivity}: Android.view.InflateException: Binary XML file line #6: Error inflating class fragment
at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2389)
at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:2441)
at Android.app.ActivityThread.access$900(ActivityThread.Java:151)
at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1354)
.........
Caused by: Android.view.InflateException: Binary XML file line #6: Error inflating class fragment
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:713)
at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:755)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:492)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:397)
..........
Caused by: Java.lang.RuntimeException: The API key can only be specified once. It is recommended that you use the meta-data tag with the name: com.google.Android.geo.API_KEY in the <application> element of AndroidManifest.xml
at com.google.maps.api.Android.lib6.c.ad.a(Unknown Source)
at com.google.maps.api.Android.lib6.a.e.a(Unknown Source)
at com.google.Android.gms.maps.internal.CreatorImpl.b(Unknown Source)
Manifast.xmlメタタグ
<manifest xmlns:Android="http://schemas.Android.com/apk/res/Android"
package="com.exampl.t_collect"
Android:versionCode="1"
Android:versionName="1.0" >
<uses-sdk
Android:minSdkVersion="14"
Android:targetSdkVersion="21" />
<uses-permission Android:name="Android.permission.INTERNET" />
<uses-permission Android:name="Android.permission.CALL_PHONE" />
<uses-permission Android:name="Android.permission.ACCESS_FINE_LOCATION" />
<uses-permission Android:name="com.Android.alarm.permission.SET_ALARM" />
<!--
To retrieve OAuth 2.0 tokens or invalidate tokens to disconnect a user. This disconnect
option is required to comply with the Google+ Sign-In developer policies
-->
<uses-permission Android:name="Android.permission.USE_CREDENTIALS" />
<Android:uses-permission
Android:name="Android.permission.WRITE_EXTERNAL_STORAGE"
Android:maxSdkVersion="18" />
<Android:uses-permission Android:name="Android.permission.READ_PHONE_STATE" />
<Android:uses-permission
Android:name="Android.permission.READ_EXTERNAL_STORAGE"
Android:maxSdkVersion="18" />
<Android:uses-permission Android:name="Android.permission.READ_CALL_LOG" />
<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 ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission Android:name="Android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature
Android:glEsVersion="0x00020000"
Android:required="true" />
<application
Android:allowBackup="true"
Android:debuggable="true"
Android:icon="@drawable/ic_launcher"
Android:label="@string/app_name"
Android:theme="@style/AppTheme" >
<activity
Android:name="com.exampl.t_collect.activity.Login"
Android:label="@string/app_name"
Android:launchMode="singleTask" >
<intent-filter>
<action Android:name="Android.intent.action.MAIN" />
<category Android:name="Android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Dash"
Android:label="@string/app_name" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Collection"
Android:label="@string/title_activity_collection" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Collection1"
Android:label="@string/title_activity_collection" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Collection2"
Android:label="@string/title_activity_collection" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Advance"
Android:label="@string/title_activity_advance" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Customer"
Android:label="@string/title_activity_customer" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Data_store"
Android:label="@string/title_activity_data_store" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.DataRqeuset"
Android:label="@string/title_activity_data_rqeuset" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.Settings"
Android:label="@string/title_activity_settings" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.PastData_activity"
Android:label="@string/title_activity_past_data" >
</activity>
<meta-data
Android:name="com.google.Android.gms.version"
Android:value="@integer/google_play_services_version" />
<receiver Android:name="com.exampl.t_collect.util.UploadGPS" />
<activity
Android:name="com.exampl.t_collect.activity.findTrucks"
Android:label="@string/title_activity_find_trucks" >
</activity>
<meta-data
Android:name="com.google.Android.geo.API_KEY"
Android:value="AIzaSy*********************************" />
<meta-data
Android:name="com.google.Android.maps.v2.API_KEY"
Android:value="@string/google_maps_key" />
<activity
Android:name="com.exampl.t_collect.activity.MapsActivity"
Android:label="@string/title_activity_maps" >
</activity>
<activity
Android:name="com.exampl.t_collect.activity.MapActivity"
Android:label="@string/title_activity_map" >
</activity>
<!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
<activity
Android:name="com.google.Android.gms.ads.AdActivity"
Android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
Android:theme="@Android:style/Theme.Translucent" />
<activity
Android:name="com.google.Android.gms.ads.purchase.InAppPurchaseActivity"
Android:theme="@style/Theme.IAPTheme" />
<meta-data
Android:name="com.google.Android.gms.wallet.api.enabled"
Android:value="true" />
<receiver
Android:name="com.google.Android.gms.wallet.EnableWalletOptimizationReceiver"
Android:exported="false" >
<intent-filter>
<action Android:name="com.google.Android.gms.wallet.ENABLE_WALLET_OPTIMIZATION" />
</intent-filter>
</receiver>
</application>
"com.google.Android.maps.v2.API_KEY"
メタデータエントリを削除します。
"com.google.Android.geo.API_KEY"
エントリは、マップサービスとプレイスサービスの両方に十分です。
出典: https://code.google.com/p/gmaps-api-issues/issues/detail?id=7824
編集-Googleはドキュメントを更新し、これを今すぐ明示的に呼びかけます