Search code examples
wear-osandroid-wear-data-api

Build error Bind_Listener is deprecated


When I try to build my apk, it gives me error saying

Error:(190) Error: The com.google.android.gms.wearable.BIND_LISTENER action is deprecated.

This is my AndroidManifest looks right now

    <service
        android:name=".MyDeviceListenerService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action
                android:name="com.google.android.gms.wearable.BIND_LISTENER"/>
        </intent-filter>
    </service

Solution

  • Since Play Services 8.2, Bind_Listener has been deprecated.

    The newer way is to use the fine grained intent filter API by specifying only the events you want to get notified for.

    To get messages from the app all the time, change Bind_Listener to something like this

    <service
        android:name=".MyDeviceListenerService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
            <data android:scheme="wear" android:host="*" android:pathPrefix="/request-network" />
        </intent-filter>
    </service>
    

    You can read more about it on the documentation.