zooter
zooter

Reputation: 2208

PlaceAutoComplete not working in signed apk

I have a very strange issue. PlaceAutoComplete was working fine in my debug apk. But now in my signed apk, the autocomplete fragement shows, but if i type anything it just returns back to the previous screen without doing anything. Here is the snippet from my MainActivity:

                    try {

                        Intent intent =
                                new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
                                        .build(MainActivity.this);

                        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_START);
                    }catch(GooglePlayServicesRepairableException e){
                        // TODO: Handle the error.
                        Toast.makeText(MainActivity.this, "Error in GooglePlayServicesRepairable", Toast.LENGTH_LONG).show();
                    }catch(GooglePlayServicesNotAvailableException e){

                        Toast.makeText(MainActivity.this, "Error in PlayServiesNotAvbl", Toast.LENGTH_LONG).show();
                        // TODO: Handle the error.
                    }

Btw, none of the Toast messages are coming, so I'm not sure if the problem is there.

My AndroidManifest file is as below for the permissions

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

(Not sure if ACCESS_NETWORK_STATE and READ_GSERVICES are required. I added these 2 after reading here on StackOverflow that it solved some users problem

This is really driving me nuts. Is there any library that I need to add to my production apk? The size seems almost 1 mb less than the debug one....

Thanks in advance

Note that API key is fine as the same works in debug mode

Upvotes: 2

Views: 1276

Answers (1)

zooter
zooter

Reputation: 2208

The problem was a combination of 2 things -

1) Publish Key was not available as mentioned in the comment - https://developers.google.com/places/android-api/signup#release-cert - however, I just want to add that you don't need a different API key for PROD, but can add your signed fingerprint to existing API (please see the link)

and

2) I had to add the API key to the release/google_maps_api.xml as mentioned by this answer - https://stackoverflow.com/a/30559898/5662769

Hope this helps somebody else too

Thanks to all who helped out

Upvotes: 1

Related Questions