Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

enter image description here

like image 359
Palak Avatar asked Dec 04 '22 02:12

Palak


1 Answers

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"
}
like image 90
Gabriele Mariotti Avatar answered Dec 14 '22 22:12

Gabriele Mariotti