0

Im trying to make a service that tracks the phone with the google fused location api but the GoogleApiClient can't connect to LocationService.API This is the message i get when i search in the console for google api client Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}

The GoogleApiClient code i used to connect is this

mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(LocationServices.API)
        .build();

just like every tutorial on the internet tells me to use.

Do anyone know why this doesn't work for me? I can get the gps position from the android api.

Tilion
  • 103
  • 4
  • 10
  • Are you making one request to connect? Or multiple? You may have an outdated version of Google Play Services. Also, read [this](http://stackoverflow.com/questions/30314765/api-unavailable-google-api-client) thread – andrewdleach Jun 30 '15 at 22:14
  • None, Maybe thats why? I just added it to the onCreate to see if that works. Thank you for noticing that – Tilion Jun 30 '15 at 22:19
  • Yes that is why! Thank you<3 I have been trying to figure this out for over 4 hours... – Tilion Jun 30 '15 at 22:21
  • Excellent! That is great news. – andrewdleach Jun 30 '15 at 22:22

1 Answers1

0

From discussion, it sounds like you are not making multiple connection requests (if necessary) to the api client. Also, try adding the following permissions to the manifest.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
andrewdleach
  • 2,458
  • 2
  • 17
  • 25