Skip to main content
added 230 characters in body; edited title
Source Link
greg
  • 1.2k
  • 2
  • 24
  • 52

Sending message Message from custom Android App to WearOS Pixel Watch 3 App fails silently or throws "Failed to deliver message to AppKey"

Update: I can get messages in now, but facing this error where on the WearOS app instead of showing the message text I get "i can see the messages coming in now, but getting this error "Failed to deliver message to AppKey"

Sending message from custom Android App to WearOS Pixel Watch 3 App fails silently

Message from Android App to WearOS App fails silently or throws "Failed to deliver message to AppKey"

Update: I can get messages in now, but facing this error where on the WearOS app instead of showing the message text I get "i can see the messages coming in now, but getting this error "Failed to deliver message to AppKey"

Source Link
greg
  • 1.2k
  • 2
  • 24
  • 52

Sending message from custom Android App to WearOS Pixel Watch 3 App fails silently

All of my apps us the same namespace uno.greg.music

Phone

In my Main Activity I am calling a function to send a message to my app deployed to my watch

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        setSupportActionBar(binding.appBarMain.toolbar)

        binding.appBarMain.fab.setOnClickListener { view ->
            Log.d("PhoneApp", "To watch")


            CoroutineScope(Dispatchers.Main).launch { sendWatch() }



            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .setAnchorView(R.id.fab).show()
        }
        val drawerLayout: DrawerLayout = binding.drawerLayout
        val navView: NavigationView = binding.navView
        val navController = findNavController(R.id.nav_host_fragment_content_main)
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        appBarConfiguration = AppBarConfiguration(
            setOf(
                R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow
            ), drawerLayout
        )
        setupActionBarWithNavController(navController, appBarConfiguration)
        navView.setupWithNavController(navController)
    }

Further below I have the send function

    suspend fun sendWatch() {
        withContext(Dispatchers.IO) {
            try {
                Log.d("PhoneApp", "threadddddd")
                val nodes = Tasks.await(Wearable.getNodeClient(this@MainActivity).connectedNodes)
                for (node in nodes) {
                    Log.d("PhoneApp", "Node ... " + node.id)
                    Log.d("PhoneApp", "Node ... " + node.isNearby)
                    Log.d("PhoneApp", "Node ... " + node.displayName)
                    Tasks.await(
                        Wearable.getMessageClient(this@MainActivity)
                            .sendMessage(node.id, "/open-app", "Hello Wear!".toByteArray())
                    )
                }
            } catch (e: Exception) {
                Log.d("PhoneApp", "Failed to send message to Node ... " + e.toString())
                e.printStackTrace()
            }
        }
    }

Logs look good, but this is my issue. I can see the Phone capturing the node data it wants to send, but the logs from my WearOS show nothing. Leading me to believe data is not being sent to my watch or my watch is not properly receiving the data.

2025-09-09 22:02:57.375 17513-17513 PhoneApp                uno.greg.music                       D  To watch
2025-09-09 22:02:57.385 17513-18941 PhoneApp                uno.greg.music                       D  threadddddd
2025-09-09 22:02:57.388 17513-18941 PhoneApp                uno.greg.music                       D  Node ... 5327nds
2025-09-09 22:02:57.388 17513-18941 PhoneApp                uno.greg.music                       D  Node ... true
2025-09-09 22:02:57.388 17513-18941 PhoneApp                uno.greg.music                       D  Node ... Pixel Watch 3

Watch

package uno.greg.music.ui

import android.content.Intent
import android.os.Bundle
import android.util.Log
import com.google.android.gms.wearable.WearableListenerService
import com.google.android.gms.wearable.MessageEvent
import uno.greg.music.R

class MyWearListenerService : WearableListenerService() {

    override fun onCreate() {
        Log.d("WearDebug", "Service runningnnnignigniignignign")
    }

    override fun onMessageReceived(event: MessageEvent) {
        Log.d("WearDebug", "Message received: path=${event.path}, data=${String(event.data)}")

        if (event.path == "/open-app") {
            Log.d("WearDebug", "Handling /open-app message")
            val intent = packageManager.getLaunchIntentForPackage(packageName)
            intent?.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
            startActivity(intent)
        }
    }
}

I made sure this listener is defined in my manifest so that the system runs it on the watch for me.

        <service
            android:name=".ui.MyWearListenerService"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
            </intent-filter>
        </service>