Google PlacePicker Closes Immediately After Launch

前端 未结 7 1705
不知归路
不知归路 2021-01-07 16:16

I am developing an Android Application and was looking into Google Places for some functionality within the application. Google has recently released the PlacePicker feature

相关标签:
7条回答
  • 2021-01-07 16:57

    I had the same problems using the Places API. 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)
  • 2021-01-07 16:58

    Just enable Google Places API for Android in your Google Developer Console.

    Don't forget to specify your API key at AndroidManifest:

    <meta-data
      android:name="com.google.android.geo.API_KEY"
      android:value="ADD_YOUR_API_KEY_HERE" />
    
    0 讨论(0)
  • 2021-01-07 16:59

    I believe that when Google made changes to their API's on 04/20/2015 they modified the places API that the PlacePicker inherently uses. The solution that worked for me is as follows:

    1. Go to your Google Developer Console (https://console.developers.google.com/project)
    2. Navigate to your project if you have made one. If not go here: https://developers.google.com/console/help/
    3. Navigate to "APIs & auth" then to "Credentials" on the left side of the console. I don't have enough rep to post a picture for guidance...
    4. Create a new Key, this appears under Public API access in your Credentials window. You will need your SHA1 Fingerprint to receive the key. Directions that I used are here: How to get the SHA-1 fingerprint certificate in Android Studio for debug mode?
    5. The location that you input your SHA1 Fingerprint should be in this format: (Your Key, 20 Hex values separated by ":");com.yourpackage.yourapp
    6. Copy your API Key that is generated. You will need to add the fingerprint of each developer in the same format above for it to work for other developers.
    7. Add your key to your AndroidManifest.xml

    <application ...
    
    <meta-data
                android:name="com.google.android.geo.API_KEY"
                android:value="@string/google_api_key" />
    
    ... </application>
    Where the "@string/google_api_key" /> is the key that you just generated. Place it in your strings.xml file as such:

    <string name="google_api_key">yourkeyhere</string>
    
    1. Clean and Rebuild your project. Should be working now. I don't think I left any steps out... Please comment if I have.
    0 讨论(0)
  • 2021-01-07 16:59

    I have the same issue. I add Google map key

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

    The Place Picker closes immediately. Then, i also add

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

    The Place Picker shows, but when i open map, my app was force close, and log like below.

    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.maps.v2.API_KEY in the <application> element of AndroidManifest.xml
            at com.google.maps.api.android.lib6.d.fb.a(Unknown Source)
            at com.google.maps.api.android.lib6.a.g.a(Unknown Source)
            at com.google.android.gms.maps.internal.CreatorImpl.b(Unknown Source)
            at com.google.android.gms.maps.internal.CreatorImpl.b(Unknown Source)
            at com.google.android.gms.maps.internal.i.onTransact(SourceFile:62)
            at android.os.Binder.transact(Binder.java:364)
            at com.google.android.gms.maps.internal.zzc$zza$zza.zzj(Unknown Source)
            at com.google.android.gms.maps.SupportMapFragment$zzb.zzqs(Unknown Source)
            at com.google.android.gms.maps.SupportMapFragment$zzb.zza(Unknown Source)
            at com.google.android.gms.dynamic.zza.zza(Unknown Source)
            at com.google.android.gms.dynamic.zza.onCreate(Unknown Source)
            at com.google.android.gms.maps.SupportMapFragment.onCreate(Unknown Source)
            at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:456)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5103)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
            at dalvik.system.NativeStart.main(Native Method)
    

    I try to remove

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

    but keep

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

    And It's working well, now, and I don't know why.

    0 讨论(0)
  • 2021-01-07 17:08

    How i fixed this error was when getting an API key (On Google Developers Page) , the location where you enter your package name enter your complete package name. This is available in your android manifest!

    0 讨论(0)
  • 2021-01-07 17:15

    replace your meta data tag in the mainfeast .. it works for me ..

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="YOUR ANDROID KEY" />
    

    with

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

    good luck

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