Android Place Picker closes immediately after launch

半腔热情 提交于 2019-11-26 20:23:21
Sampath Janardhan

Francois Wouts' solutions helped answer this. Thank you Francois...

I searched the logs with keyword 'Places' and found that Places API was indeed throwing an exception. It expected the com.google.android.geo.API_KEY within the <application> tags in the Manifest.xml.

I had changed to com.google.android.geo.API_KEY in the <activity> tag and not the one in the <application> tag.

Now changed to com.google.android.geo.API_KEY and removed the same lines from <activity> tag, and got it working. Feel like an idiot for not working this out by myself..

The meta-data tag should read android:name="com.google.android.geo.API_KEY"
It should be within the <application> tag in the Manifest.

Francois Wouts

Have you double checked that your API key is associated with your application (package name and SHA-1 fingerprint of your app's certificate) in the Developer Console?

You can find instructions at Signup and API Keys. Make sure to set it up for both your debug and your release certificates.

I hope that helps!

Anirban

I was having the same issue. Make sure you enable Google Places API for Android and not just Places API in the Developer Console. "Places API for Android" will not show up under APIs & Auth/APIs because it isn’t a popular API (yet). You will have to search for it using the API search box.

In manifest file com.google.android.geo.api_key and com.google.android.maps.v2.API_KEY shouldnot be same.

go to https://console.developers.google.com/project

login and follow these steps to get key for placepicker places.

create or choose existing > use google apis > Google Places API for Android > enable > credentials in left menu > add credentials > api key > android key > create > copy key.

paste your key at manifest "com.google.android.geo.api_key"

Note : there is a limit of 1000 requests per day for google places api. after you have to pay money. Better to avoid PlacePicker.

This issue made me crazy as well, there are so many issues regarding exactly this problem, but no one was helpful for me. At the end, I figured out that there are different Google Places APIs especially for Android. Consequently, the API-Key that I was using was simply for the non-Android version.

Generate your key using this link https://developers.google.com/places/android-api/signup

May be you forgot to add your machine SHA key to the Google Maps Console. Faced same issue, Added my SHA Key to the console, it started working fine.

I filling out the Consent screen in APIs & Auth of the console and its working fine. Check the screen shot.

It was strange that it was a credentials problem for me. It works even without a warning in debugging mode but when i use released version of my app it just doesnt work (i have registered my release and debug sha1 keys) So i removed all restrictions and now its working.

Mahendra Tejaswi

Add compile 'com.google.android.gms:play-services-location:8.1.0' in gradle

In my case there was conflict of APIs. I have added google-service.json file which also had API key and I generated new key for Maps. So place picker was closing immediately. Solution :

  1. Use single API key which is in google-service.json file

  2. Enable "Places SDK for Android" feature for your Google Cloud Platform project (with same name as in Firebase project , don't use different project. You will find same name project as you are using in Firebase)

  3. Put SHA1 Application Restriction for android app (Recommended)
  4. Check if you have placed following code in Application tag only

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

I'll just drop this here, maybe it helps someone in the future.

For me, using the wrong Api key caused the crash, even though it worked fine in the past.

I had to use the second key (the one that is auto-created by Google services for Android) instead of the first one which i created.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!