Android Place Picker closes immediately after launch

后端 未结 14 1320
难免孤独
难免孤独 2020-11-27 04:57

I am developing an android application as part of a project, and am using Google places API to display places of interest based on location. I am using the PlacePicker Inent

相关标签:
14条回答
  • 2020-11-27 05:44

    In my case when I changed current API key with the one which is in google-service.json, it resolved the problem.

    In google-services.json:

     "api_key": [
            {
              "current_key": "PASTE THIS API KEY TO THE MANIFEST"
            }
          ]
    
    0 讨论(0)
  • 2020-11-27 05:45

    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

    0 讨论(0)
  • 2020-11-27 05:47

    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.

    0 讨论(0)
  • 2020-11-27 05:51

    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.

    0 讨论(0)
  • 2020-11-27 05:54

    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.

    0 讨论(0)
  • 2020-11-27 05:54

    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.

    0 讨论(0)
提交回复
热议问题