Google PlacePicker Closes Immediately After Launch
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:
- Go to your Google Developer Console (https://console.developers.google.com/project)
- Navigate to your project if you have made one. If not go here: https://developers.google.com/console/help/
- 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...
- 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?
- The location that you input your SHA1 Fingerprint should be in this format: (Your Key, 20 Hex values separated by ":");com.yourpackage.yourapp
- 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.
- 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>
<string name="google_api_key">yourkeyhere</string>
- Clean and Rebuild your project. Should be working now. I don't think I left any steps out... Please comment if I have.
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" />
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.