2

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

zooter
  • 2,128
  • 1
  • 13
  • 23
  • 1
    You need to have a different API key for your publish apk. For more info take a look at this link. [Publish Key](https://developers.google.com/places/android-api/signup#release-cert) – Shafayat Mamun Apr 25 '16 at 04:20
  • 1
    @zooter : Did you used release api key? If yes then please check your progaurd configuration..If it is not obfuscating place auto complete api..!! – AndiGeeky Apr 25 '16 at 04:45
  • @andigeeky how do I check that proguard is not obfuscating auto complete and if yes how do I stop it? – zooter Apr 25 '16 at 05:02
  • @zooter : You need to check your Android Moniter if you are getting any exception in verbose or you are getting any info like a.b() etc. – AndiGeeky Apr 25 '16 at 05:25
  • 1
    @zooter : I think you need to create release apl with `progaurd` as `false` and check if working or not :) – AndiGeeky Apr 25 '16 at 05:26

1 Answers1

1

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

Community
  • 1
  • 1
zooter
  • 2,128
  • 1
  • 13
  • 23