2014-08-27 78 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