Skip to content Skip to sidebar Skip to footer

Multiple Google Api Keys In Manifest File (android)

I am trying to add two api keys i.e Google places api key and google maps api key. But I am not able to add both at same time to manifest file.How can I achieve the same.Any help w

Solution 1:

Use following meta-data in your manifest. there is no need to create another api key for places api if you already have api key for google map. If you are using both Maps & Places Api in your application then you only need to specify geo api key.and just enable Places Api.

<meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="api_key" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

Solution 2:

Rather than adding two different API keys, for the same project enable both keys and copy down the same key as follows for single project which you want currently

<!-- Goolge Maps API Key --><meta-dataandroid:name="com.google.android.maps.v2.API_KEY"android:value="AIzaS******************WDaKCEHP" /><!-- Google Places API Key --><meta-dataandroid:name="com.google.android.geo.API_KEY"android:value="AIzaS******************WDaKCEHP" />

Solution 3:

Whats your Error log saying

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 element of AndroidManifest.xml

Just remove

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

Make sure you have below permissions . Enough for Map Showing .

<meta-dataandroid:name="com.google.android.gms.version"android:value="@integer/google_play_services_version" /><meta-dataandroid:name="com.google.android.maps.v2.API_KEY"android:value="@string/common_google_api_key" /><uses-libraryandroid:name="com.google.android.maps"android:required="false" />

Read

Getting error "java.lang.RuntimeException: Unable to start activity" in my app

Post a Comment for "Multiple Google Api Keys In Manifest File (android)"