Open gabojara opened 1 month ago
Your phone might not be on the wearos network. have you tried using the main Wear OS app to connect your phone to your watch?
My wear os doesn't work with that, it works with Galaxy Wearable https://play.google.com/store/apps/details?id=com.samsung.android.app.watchmanager
Have you tried using the Emulator in Android Studio as the first step? I'm successfully using this with a Galaxy Wearable.
You need to ensure your namespace & applicationId are the same in your Watch and Phone app
android/app/build.gradle: namespace "com.example.wearexample" android/app/build.gradle: applicationId "com.example.wearexample"
in android/app/src/main/AndroidManifest.xml, the name and permissions are defined
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.wearexample">
<!-- Permissions that the app requires -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<!-- Add this if targeting Android 12 or higher -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
3. in android/app/build.gradle you need to have your signing config setup in **BOTH Android and WearOS app** to use the same key.
`
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } ........
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}`
I'm using the following code to initialize / connect on the WearOS side.
` WatchViewModel() { print("WatchViewModel initialized"); _initWearableAPI(); _setupChannelHandler(); }
void _setupChannelHandler() { _channel.setMethodCallHandler((call) async { print("Received method call: ${call.method}"); _handleMessage(call.arguments); return null; }); }
void _initWearableAPI() { print("Initializing Wearable API"); wearOsConnectivity.configureWearableAPI().then(() { print("Wearable API configured"); _wearOsConnectivity.getConnectedDevices().then((devices) { print("Connected devices: ${devices.length}"); if (devices.isNotEmpty) { _phoneDeviceId = devices.first.id; print("Phone device ID: $_phoneDeviceId"); _listenForMessages(); } else { print("No connected devices found"); } }); }).catchError((error) { print("Error configuring Wearable API: $error"); }); } `
I'm trying to get the devices but I get errors, the same thing happens when I want to listen to the messages received on the phone.
Error: