Punpuf Punpuf - 3 months ago 55
Android Question

Android Place Picker shows blank screen when place is selected, or when trying to return

I'm trying to implement in my android app the Google Maps Places API.

When a button is clicked it opens the place picker, the picker works fine (you can move around, zoom in and out, search and go to current location), until when you try to click on the "Select this location" button; when the button is clicked a blank screen opens, and the only option is to close the app.
The same happens when the back button is pressed (either the one the navigation bar, or the one in the AppBar)

Image: Inside the Place Picker Activity

Image: Blank Screen

It was working fine a few weeks ago, then it stopped working, one day ago it started working again, and today it stopped working.

Code to open Place Picker:

private void openPlacePicker() {
Log.i(TAG, "open place picker");

PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
try {
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
}
catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}


And yes I've added a permission check for ACCESS_FINE_LOCATION, before executing the function.

Code for on Activity Result:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i(TAG, "onActivityResult");
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
final Place place = PlacePicker.getPlace(this, data);
(...)


My logs don't show any errors, and the OnActivityResult Logs aren't called:

D/libgps: proxy_gps_stop: called.
D/libgps: proxy_gps_status_cb: called.
D/libgps: proxy_gps_status_cb: called.
I/art: Background partial concurrent mark sweep GC freed 58725(4MB) AllocSpace objects, 23(2MB) LOS objects, 40% free, 14MB/23MB, paused 1.422ms total 101.850ms
D/gpsd: WakeLock(Release,GPSD)
I/Auth: [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
I/Auth: [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
I/Auth: [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/GCoreUlr: Successfully inserted 1 locations
I/WifiHAL: Got channel list with 11 channels
I/WifiHAL: Got channel list with 9 channels
I/WifiHAL: Got channel list with 13 channels
W/ActivityManager: Launch timeout has expired, giving up wake lock!


My Manifest Meta Data and Permissions:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<application
(...)

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIza(...)" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


I've check in the Google Console Page, the package name and the SHA-1 fingerprint are correct.
When I'm at Overview > Google Maps APIs > Google Places API for Android > Usage, it shows no usage what so ever, when it should be showing some, because as I said previously, one day ago it was working and I used it.

This issue has happen on my Nexus 9 (Android N), and on the Moto G3 (Android M).

Note: On the Moto G it would work the first time, user would click a button, place picker opens, user clicks on picker's "Select Location" button, goes to previous activity everything works fine; but if he clicks on the button to open the picker again, and he tries to click on picker's "Select Location" button again, he would go to the blank screen, and would have to close the app and try again).

TLDR;
The Place Picker in my android app goes to a blank screen when I try to select a location or leave the Place Picker Activity.

Thanks

Answer

As noted by my earlier comment, I had the exact same problem earlier today. What solved it for me was replacing:

compile 'com.google.android.gms:play-services:9.0.0'

with

compile 'com.google.android.gms:play-services-location:9.0.0'

This change was suggested from this Stack post

Note: If you're using more than just the location from the play-services library, make sure to include the other components like

compile "com.google.android.gms:play-services-games:9.0.0"
compile "com.google.android.gms:play-services-plus:9.0.0"
compile "com.google.android.gms:play-services-ads:9.0.0"