0

I am trying to implement two different Google Keys in the same project, the Google Places API for Android and the Google Maps Android API.

I have checked this post and this one but I believe I have a different problem

My manifest looks like this:

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

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

The error I get is the following:

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

Does this mean I cannot use another API in the same project? How do you think I can solve it?

Thanks in advance

Community
  • 1
  • 1
Alvaro
  • 1,430
  • 2
  • 23
  • 41

2 Answers2

2

You just need to Enable all the Api's(You need) in the Google Developer Console

And their has to be only one KEY for all the API's you wanted to access and Add that key into your AndroidManifest.xml.

You can enable all the Api's and Download the google-services.json from Google Developer console and Add it into your project>app

<!-- Google Maps API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA******************KDaKCEJU" />    

<!-- Google Places API Key -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyA******************KDaKCEJU" />    

This will sort out your problem.

CandleCoder
  • 1,387
  • 4
  • 21
  • 45
  • I have enabled both API and I have used the same API key for both `meta-data`, but I keep getting the error – Alvaro Feb 13 '16 at 15:15
  • In the same project(In the Google Console) you have to enable the the api's you wanted to use at google console. You have to use only one API KEY which would give you access to all the Api's you have enabled at the Google console.And this Single KEY will be added to AndroidManifest.xml.Use only one 'meta-data' – CandleCoder Feb 13 '16 at 15:18
  • yes I know, I have enabled both API in the same project (In the Google Console). Now I am using the key given from google for both API in `meta-data`, but the error I get is still the same. – Alvaro Feb 13 '16 at 15:21
  • Added some more Code check this if it helps – CandleCoder Feb 13 '16 at 15:29
0

You have to enable both services and Include the Key in the Manifest for Just one Time(not twice). you may find some solutions to your problem Here

Community
  • 1
  • 1
S.Ahsan
  • 389
  • 3
  • 15