2014-08-27 75 views
0

我试图发送消息,从手持设备到wear-emulator, (根据this tutorial)。 不幸的是我的WearableListenerService.onMessageReceived没有被调用。WearableListenerService onMessageReceived不会被解雇[android wear]

在这里,所以我看了它可以与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:+' 
} 

我已经设置了一切,因为它是在前面提到的教程。

感谢您的任何可能的答案

+0

你有没有在你的清单注册了吗? – 2014-08-28 11:05:40

+1

@Gabriele是的+我发布了一个解决方案。 – Benji 2014-08-28 11:32:33

回答

0

问题依赖于模块启动顺序,第一个推出手持式模块的应用程序,然后戴上仿真器的应用程序,而不是相反,因为我:)

+0

为什么这很重要,它是如何解决你的问题的? – 2015-02-28 07:25:39

+0

如果不保持应用程序的正确顺序,则无法互相连接。至少在我遇到这个问题时是如此。 – Benji 2015-03-06 20:25:04

0

以前做过的工作对我来说

如果您使用Proguard的保护您的APK,您需要确保GSON类不会Proguard的,如果你使用GSON类

像这样 ProGuard for Android and GSON

然后,你必须确保你的手机上的APK和磨损必须具有相同的签名,换句话说,你需要使用相同的密钥存储文件导出烧焦APK。

+0

您应该在此粘贴相关链接内容以避免死链接问题 – 2015-01-04 13:54:10