简体   繁体   中英

Having multiple meta-data in Manifest file

In my application i am using one or more services so i included the meta data in my manifest . But my problem is when using only one meta tag works fine but having multiple tags throws error.
Here is my Manifest.xml

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="place.picker.mymarket">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
    <activity android:name=".oneTimeValidation">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".MainActivity" />
    <activity android:name=".MapsActivity"/>
    <activity android:name=".list_my_posts" android:label="deletion list" />
    <activity android:name=".Upload_to_server"></activity>
    <meta-data android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_place_api" />
    <meta-data
    android:name="com.google.android.geo.API_KEY1"
    android:value="@string/google_maps_key" />
</application>
</manifest>

It throws Error :

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

Can Anyone help me how to have multiple meta-tags in manifest please.

Open the manifest and click on Merged manifest

在此处输入图片说明

At the right column, you'll find more details about the error, something like the following message.

在此处输入图片说明

I don't think it's good idea to declare both of them when you just need one, but if by any chance you still want to do it then, just use one key for it. One key will work for both service.

<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="@string/google_places_api_key" />    

<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_places_api_key" />  

Hope it helps you.

You can't declare both keys in your manifest in the same time. When you are using Google Maps and Google Places just use the Google Places API key only ( com.google.android.geo.API_KEY ), and it will work for both.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM