2015-10-14 79 views
2

我能够将GCM集成到应用程序模块中,但无法集成到库模块中。我在应用程序模块中包含这两行代码。无法将Google Cloud Messaging集成到Android库模块中

apply plugin: 'com.android.library' 
apply plugin: 'com.google.gms.google-services' 

我在应用程序模块的依赖关系中有这行代码。

compile 'com.google.android.gms:play-services-gcm:8.1.0' 

而且这条线是在项目顶层

classpath 'com.google.gms:google-services:1.4.0-beta3' 

但是,当我试图通过扩展GcmListenerService实现服务,它是无法检测GcmListenerService。

请给出建议,我试图超过5小时,但无法解决问题。

+0

只要加入'编“com.google.android.gms:播放 - services-gcm:7.5.0''在您的应用程序gradle文件中。没有别的 –

+0

我已经添加了你正在谈论的代码,但没有结果。 – Madhu

+0

删除您添加的任何依赖关系 –

回答

0

首先,你必须通过添加以下代码的应用程序gradle这个文件添加GCM罐子到项目

ependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:23.0.1' 
    compile 'com.android.support:design:23.0.1' 
    compile files('libs/gcm.jar') 
} 

然后同步项目

+0

我们不需要gcm.jar了。 – Madhu

相关问题