Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlaceAutocomplete got unknown status code: 9000

I reused the code from Google PlaceAutocomplete sample project by Android team.

I used different key for each project (also enabled Google Places for Android in google console).

When I build and run the sample project, it was working without problem.

However, when i run it from my app, sometimes it's working, other times I got unknown status code: 9000 (from status.toString()).

I got this on the console:

04-08 01:15:39.331  16148-10791/? W/Places﹕ f.a:633: gLocReplyElement unsuccessful status: 1

04-08 01:15:39.332  16148-10791/? W/Places﹕ f.a:660: gPlaceQueryResult unsuccessful responseCode: 26

04-08 01:15:39.339  10558-11608/com.travelapp.karet W/karet﹕ Error getting autocomplete prediction API call: Status{statusCode=unknown status code: 9000, resolution=null}

It's very strange, so when I type s,i (start suggesting places),n,g . So when I reached the fourth letter I occasionally got this error.

So the only part that was different was only the int value clientId that I passed to mgoogleApiClient.enableAutoManage()

The sample project use 0, while my project use 9993938838939 (random number). -I'm not sure what value should I put here (it rejected number that's already used by other app)

Other than that, the codes was no different (only that I put the googleclient variable on Activity, but the actual Autocomplete implementation on a Fragment)

Please help.

like image 555
Anton R Avatar asked Apr 05 '15 16:04

Anton R


3 Answers

I faced the same problem and was able to solve it. There are 3 things to be done in the manifest file to make the demo work:

1- Add <uses-permission android:name="android.permission.INTERNET" />, If not already there.

2- Replace ADD_YOUR_API_KEY_HERE with your api key. You can generate an api key by using this link: Google Places Sign Up.

3- Add Android application package of demo app to the list of allowed apps like this: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;com.example.google.playservices.placecomplete

To add to the list of allowed apps, visit the Google Developers Console. Then select the project you're working on. On the left hand side, click on the "APIs & auth" link, and below that click on the "Credentials" link. After that, click on the "Edit allowed Android applications" button. Now you can enter application package of the demo app e.g. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;com.example.google.playservices.placecomplete in the text box.

Note: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX = YOUR SHA1 certificate fingerprint

like image 139
Asif Mujteba Avatar answered Oct 02 '22 08:10

Asif Mujteba


Ensure that you have added the required values to your AndroidManifest.xml

Permission:

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

Meta-Data:

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

Take a look at the Sample AndroidManifest.xml here

like image 43
Nic Avatar answered Oct 02 '22 08:10

Nic


Please ensure the folowing.

1. The package name given in console registration page must be same as that of actvity/fragment we are using. ie; if are using this auto search button inside com.example.rajeesh.UI.fragements.SearchFragment, 
then inside console registration page  package name should be 
com.example.rajeesh.UI.fragements
This is different from the package name we given in manifest file.

2. Inside manifest please  change 
  <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="@string/google_maps_api_key" />
to

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


3. Enable Google Places API for Android in console page.
like image 29
rajeesh Avatar answered Oct 02 '22 08:10

rajeesh