我正在尝试实施 Google Cloud Messaging(GCM)的示例代码,该代码由Google自己提供,GCM Demo。
我不知道我究竟能添加依赖项
答案 0 :(得分:14)
如link中所述。
将依赖项添加到项目的顶级build.gradle
:(只需编辑文件)
classpath 'com.google.gms:google-services:1.3.0-beta1'
你应该像这样闷闷不乐:
//顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
然后将插件添加到您的应用级build.gradle
(只需编辑文件):
apply plugin: 'com.google.gms.google-services'
你应该像这样闷闷不乐:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
//..
}
最后在您的应用级build.gradle
dependencies {
compile "com.google.android.gms:play-services:7.5.0"
}