Gradle where exactly to put "apply the plugin"?

I am trying to add Google analytics to my application using this tutorial:

https://developers.google.com/analytics/devguides/collection/android/v4/

But I'm stuck in a problem where to put the line exactly:

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

So, the top level file build.gradle looks 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'
        apply plugin: 'com.google.gms.google-services'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

But it's not right. Where, please, attach the plugin?

Thanks for any help.

+4
source share
3 answers

In andriod studio you have this structure:

root
   build.gradle
   app
      build.gradle

In the top level of build.gradle you have:

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

allprojects {
    repositories {
        jcenter()
    }
}

IN app/build.gradle

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

 //...


dependencies{
   //.....
   compile 'com.google.android.gms:play-services-analytics:7.3.0'
}
+3
source

Must be inside the object

allprojects 
0
source

build.grade

:

apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
0
source

All Articles