我正在尝试一个由谷歌提供的实现Google Cloud Messaging (GCM)的示例代码,GCM演示。
我不知道如何添加依赖项。
- 将依赖项添加到项目的顶层build.gradle中:
- 当我转到Project Structure > Modules > Add,然后选择Module Dependency时,会出现一个弹出屏幕,显示没有要依赖的模块。 如果有其他添加依赖项的方法,则需要帮助。 我已经附上了相关的图片。
我正在尝试一个由谷歌提供的实现Google Cloud Messaging (GCM)的示例代码,GCM演示。
我不知道如何添加依赖项。
如链接所述。
将依赖项添加到项目的顶层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"
}
volley
来进行HTTP请求。我希望只需在顶层gradle脚本中添加一次volley
,就可以结束了。 - Saeed Neamati