2015-11-12 7 views
15

पर निर्दिष्ट किया जा सकता है, मैं ऐप में Google मानचित्र जोड़ने की कोशिश कर रहा हूं, इसलिए मैंने एपीआई कुंजी ली है। दुर्भाग्य से जब मैंने मेटा-डेटा टैग के माध्यम से manifest.xml में एपीआई कुंजी डाली, तो यह नीचे दिखाए गए संकलन समय पर स्वचालित रूप से एक और मेटा-डेटा टैग डाला। अब यह नीचे उल्लिखित त्रुटि उत्पन्न करता है। सबसे बुरा मामला है, यहां तक ​​कि मैं उनमें से प्रत्येक या दोनों को हटा देता हूं, यह स्वचालित रूप से संकलन समय पर दोनों टैग उत्पन्न करता है और त्रुटि फेंकता है।एंड्रॉइड - एपीआई कुंजी केवल <meta-data> डुप्लिकेट

कोई मदद?

त्रुटि

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> 

+0

आप हमें पूरे प्रकट दिखा सकते हैं फाइल? – Emil

+0

अपडेट किया गया। धन्यवाद – user2486322

+0

अपने मैनिफेस्ट से इस मेटा डेटा टैग को 'com.google.android.geo.API_KEY' आज़माएं और निकालें। मुझे नहीं पता कि इसका पुनर्जन्म क्यों हुआ। क्या आप सही मैनिफेस्ट फ़ाइल संपादित कर रहे हैं? '(ऐप/src/main/AndroidManifest.xml)' – Emil

उत्तर

51

अपनी "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


संपादित करें - गूगल अपने दस्तावेज़ों अद्यतन स्पष्ट रूप से यह पता अब कॉल करने के लिए:

  1. https://developers.google.com/places/android-api/start#api-key
  2. https://developers.google.com/maps/documentation/android-api/signup#add_the_api_key_to_your_application
+0

यह उत्तर है, धन्यवाद – sdelvalle57

+0

यह एकदम सही समाधान है – R2R

संबंधित मुद्दे