Android Wear: Unable to connect to GmsClient com.google.android.gms.LIGHTWEIGHT_INDEX

3.6k Views Asked by At

I am working Data Layer on Android Wear, which trying to send DataItem (using Data API) from the Wearable (Moto 360 Gen1) to my mobile devices.

However, there is no sign of error or connection failed, and the data is not sent. The only message error I received is

E/Gms Client: unable to connect to service: com.google.android.gms.icing.LIGHTWEIGHT INDEX SERVICE'

In mobile:

I have created a Wearable Listener Service to receive data in onDataChanged(DataEventBuffer dataEvents)

Android Manifest

<service
        android:name=".ListenerService">
    <intent-filter>
        <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
    </intent-filter>
</service>

In Wear Activity:

Header of Activity looks like

public class MainActivity extends WearableActivity implements
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener{

I have a GoogleApiClient in my onCreate(..) function:

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

mGoogleApiClient.connect();

@Override
public void onConnected(Bundle bundle) {
    Log.d("Android Wear Connection", "" + mGoogleApiClient.isConnected());

    //Data Layer Function uses Data Map
    sendAmplitudeDb(10, 2300);
}

I really stucked and no clue why the mobile device is not receiving any data items, or why is the wearable cannot connect to the Google Api Client... Please help!

Also, I have implemented almost the same code as following git repo: https://github.com/LarkspurCA/WearableDataMap

2

There are 2 best solutions below

2
On

Make sure that the service tag is within the application tag in the manifest, perhaps?

0
On

I had similar problem, I eventually came to a solution, I disabled all calls to connection validation that I was performing before setting data item. Turns out, I was not having the DataReading/ListenerService on mobile(actually I did not have the mobile app at all as I was working with watchface).

Check if you have import com.google.android.gms.* imported in the project and you are establishing a connection or validating it in order to establish communication between devices, where the other device is not having a listener service