Skip to content Skip to sidebar Skip to footer

Getplacebyid() Fails To Return Data On Android Google Places Api / Resultcallback Not Getting Called

I cannot retrieve Place Details using the Google Places API on Android. I'm calling getPlacyById() for specific place_id. Inside an Android activity I setup a googleApiClient and c

Solution 1:

UPDATE for SDK 21

If you have both meta-data's included you will get the following error:

 Caused by: java.lang.RuntimeException: The API key can only be specified once.

Instead just indlude the geo API key:

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

and NOT the maps one

Solution 2:

This exactly what I've been struggling with. In Android Studio when I added the 2nd API key I received an exception:

 Caused by: java.lang.RuntimeException: The API key can only be specified once.

This was resolved by just adding the "com.google.android.geo.API_KEY" meta-data entry to the Manifest file and removing the maps one.

Solution 3:

I was missing two things.

First of all the com.google.android.geo.API_KEY which is the same as the com.google.android.maps.v2.API_KEY. Just copy paste the API KEY on the AndroidManifest file.

android:name="com.google.android.maps.v2.API_KEY" android:value="whatEverGoogleMapsApiKeyYouHave"

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

I was also missing the Google Places API for Android Service on google console. If you have Google Places API enabled , beware, this in not enough, because it's simply a different API. You have to go to google console and explicitly enable the Google Places API for Android.

****** EDIT ******** As @Lissy pointed out, from SDK 21 onwards, defining the same API_KEY twice will give an error. Keeping the geo.API_KEY will suffice

Post a Comment for "Getplacebyid() Fails To Return Data On Android Google Places Api / Resultcallback Not Getting Called"