简体   繁体   中英

How to add dependencies to project's top-level build.gradle file?

I'm trying a sample code which implements Google Cloud Messaging (GCM) and that is provided by google itself, GCM Demo .

I don't know how exactly I can add the dependencies

  • List item
  • Add the dependency to your project's top-level build.gradle:
  • When I go to Project Structure > Modules > Add and then select Module Dependency then a pop up screen appears for no module found to depend on. If there is another way I can add the dependencies then a help would be appreciated.I have attached an image regarding the same.

在此输入图像描述

As described in the link .

Add the dependency to your project's top-level build.gradle : (just edit the file)

classpath 'com.google.gms:google-services:1.3.0-beta1'

You should have somenthing like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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
    }
}

Then add the plugin to your app-level build.gradle (just edit the file):

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

You should have somenthing like this:

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

android {
  //..
}

Finally add the dependency in your app-level build.gradle

dependencies {
  compile "com.google.android.gms:play-services:7.5.0"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM