我能够将 GCM 集成到应用程序模块中,但无法集成到库模块中。我在应用程序模块中有这两行。
apply plugin: 'com.android.library'
apply plugin: 'com.google.gms.google-services'
我在 app 模块的依赖项中有这行代码。
compile 'com.google.android.gms:play-services-gcm:8.1.0'
这条线在项目顶层
classpath 'com.google.gms:google-services:1.4.0-beta3'
但是当我尝试通过扩展 GcmListenerService 来实现服务时,却无法检测到 GcmListenerService。
请提出建议,我尝试了 5 个多小时但无法解决问题。
最佳答案
首先,您通过将以下代码添加到应用程序 gradle 文件中,将 gcm jar 添加到您的项目中
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')
}
然后同步项目
关于java - 无法将 Google Cloud Messaging 集成到 android 库模块中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33125753/