PlaceAutocomplete received an unknown status code: 9000

I reused the code from the Google PlaceAutocomplete project example from the Android team.

I used different keys for each project (Google Places for Android is also included in the Google console).

When I create and run a sample project, it works without problems.

However, when I run it from my application, sometimes it works, sometimes I got an unknown status code: 9000 (from status.toString ()).

I got this on the console:

04-08 01:15:39.331 16148-10791/? W/Places﹕ fa:633: gLocReplyElement unsuccessful status: 1 04-08 01:15:39.332 16148-10791/? W/Places﹕ fa: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} 

This is very strange, so when I type s, I (start offering places), n, g. Therefore, when I reached the fourth letter, I sometimes got this error.

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

The sample project uses 0, while my project uses 9993938838939 (random number). -I'm not sure what value I should put here (he rejected a number that is already in use by another application)

Also, the codes were not different (only I put the googleclient variable in Activity, but the actual implementation of Autocomplete on the fragment)

Please, help.

+6
source share
3 answers

I ran into the same problem and was able to solve it. There are 3 things in the manifest file to do a demo:

1- Add <uses-permission android:name="android.permission.INTERNET" /> if it does not already exist.

2- Replace ADD_YOUR_API_KEY_HERE with the api key. You can generate the api key using this link: Register Google Places .

3. Add the application package to demonstrate the Android application to the list of allowed applications: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;com.example.google.playservices.placecomplete

To add a list of allowed apps, visit the Google Developer Console . Then select the project you are working on. In the left part, click the "API and Authorization" link, and below - the "Credentials" link. After that, click the "Edit Allowed Android Apps" button. Now you can enter the application package of the demo application, for example. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;com.example.google.playservices.placecomplete in the text box.

Note: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX = YOUR SHA1 fingerprint certificate

+6
source

Make sure you add the required values ​​to your AndroidManifest.xml

Resolution:

 <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

+3
source
 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. 
+2
source

Source: https://habr.com/ru/post/984707/


All Articles