WearableListenerService onMessageReceived不会被触发[android wear]

时间:2014-08-27 11:05:12

标签: android wear-os

我正在尝试发送信息从掌上电脑发送到模拟器, (根据this tutorial)。 不幸的是,我的WearableListenerService.onMessageReceived没有被调用。

在这里,我已经读过它可能与gradle.build文件有某种关系,

我的gradle.build in' mobile'模块(手持):

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:+'
}

我在前面提到的教程中设置了其他所有内容。

感谢任何可能的答案

2 个答案:

答案 0 :(得分:0)

问题依赖于模块启动顺序,首先启动手持模块应用程序,然后再穿模拟器应用程序,反之亦然,如我之前所做的那样:)

答案 1 :(得分:0)

这对我有用

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

喜欢这个 ProGuard for Android and GSON

然后你必须确保你手机上的apk和穿戴必须有相同的签名,换句话说,你需要使用相同的KeyStore文件来导出烧焦的APK。