androidwear-osandroid-wear-data-apiandroid-wear-2.0

Error while accessing android wear data layer


I am trying to access the wearable data layer to communicate with the phone app as shown here.

However, after writing the following line:

DataClient dataClient = Wearable.getDataClient(context);

The Android lint flags it in Android Studio and shows the following error:

Cannot access com.google.android.gms.hasApiKey

Can anyone help me with the meaning of this error and how I can go about resolving it.

P.S.: I have already integrated the Google Play Services API by adding the necessary configuration to my gradle files.


Solution

  • I encountered that error too (while using a feature of the Google Play Services API):

    error: cannot access HasApiKey
    

    The solution was to explicitly add the play-services-base dependency to the project:

    implementation 'com.google.android.gms:play-services-base:17.2.1'