【问题标题】:WearableListenerService onMessageReceived will not get fired [android wear]WearableListenerService onMessageReceived 不会被解雇 [android wear]
【发布时间】:2023-04-08 06:45:01
【问题描述】:

我正在尝试从手持设备向穿戴式模拟器发送消息, (根据this tutorial)。 不幸的是,我的 WearableListenerService.onMessageReceived 没有被调用。

在这里,我读过它可能与 gradle.build 文件有关,

我的“移动”模块(手持)中的 gradle.build:

apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.example.benji.data"
    minSdkVersion 15
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.google.android.gms:play-services-wearable:+'
}

我的 gradle.build 在“磨损”模块中:

apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.example.benji.data"
    minSdkVersion 20
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}

我已经按照前面提到的教程设置了所有其他内容。

感谢任何可能的答案

【问题讨论】:

  • 您在 Manifest 中注册了吗?
  • @Gabriele 是的 + 我已经发布了一个解决方案。

标签: android wear-os


【解决方案1】:

问题取决于模块启动顺序,首先启动手持模块应用程序,然后戴上模拟器应用程序,而不是像我以前那样反之亦然:)

【讨论】:

  • 为什么这很重要,它是如何解决您的问题的?
  • 如果不保持应用程序的正确顺序,它们将无法相互连接。至少当我遇到这个问题时是这样的。
【解决方案2】:

这对我有用

如果你使用Proguard来保护你的apk,你需要确保Gson类不会是Proguard,如果你使用Gson类

像这样 ProGuard for Android and GSON

那么你必须确保你手机和wear上的apk必须有相同的签名,也就是说你需要使用相同的KeyStore文件来导出签名的APK。

【讨论】:

  • 您应该在此处粘贴链接的相关内容以避免死链接问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-05
相关资源
最近更新 更多