Couldn't connect to Google API client

25,108

Solution 1

I had the same problem

Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}

because Google Places API for Android was not enabled in the API Console.

https://developers.google.com/places/android/signup

Solution 2

I had a similar issue here. Although I was not using any Google API specifically, I was having this error too.

My scenario was: I was making a Wearable App, and wanted to send DataItem from phone to wearable. In order to do that, I was using GoogleApiClient and Wearable.DataApi.

After many hours struggling to solve the problem, I came to this post: https://android-developers.googleblog.com/2014/10/tips-for-error-handling-with-android.html.

The part on the article that was important to me was:

When requesting Wearable.API when no Android Wear companion application or device is available.

So, I solved the problem installing the Companion App on the phone: https://play.google.com/store/apps/details?id=com.google.android.wearable.app

After installing it, the ResultCallback started to return success.

Share:
25,108
makaron
Author by

makaron

Updated on August 26, 2022

Comments

  • makaron
    makaron over 1 year

    I can't fetch last known location. I have enabled Geocoding API and Google Places API for Android in google console. I added api key to manifest file:

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_api_key" />
    

    but I keep getting a message in the console: "Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}"


    UPDATE

    I use google sample

    protected synchronized void buildGoogleApiClient() {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }
    
    @Override
    public void onConnected(Bundle connectionHint) {
        Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
                mGoogleApiClient);
        if (mLastLocation != null) {
            Toast.makeText(this, "Latitude = " + mLastLocation.getLatitude() + "\n" +
                    "Longitude = " + mLastLocation.getLongitude(), Toast.LENGTH_LONG).show();
        }
    }
    
    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        Toast.makeText(this, connectionResult.toString(), Toast.LENGTH_LONG).show();
    }
    

    onConnected and onConnectionFailed do not call.

    And also I use Android-ReactiveLocation but both methods are output to the console: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}