2015-08-26 45 views
4

我試圖添加使用本教程中我的應用程序的谷歌內部分析:gradle在哪裏放「應用插件」?

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

但我stucked上的問題,在這裏正好放線:

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

所以我的build.gradle頂級文件是這樣的:

// 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() 
    } 
} 

但這是錯誤的。請在哪裏準確地申請插件?

感謝您的任何幫助。

回答

3

在Andriod的工作室你有這種結構的:

root 
    build.gradle 
    app 
     build.gradle 

在頂層的build.gradle您有:

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

在你app/build.gradle

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

//... 


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

應該是對象

allprojects 
上的應用程序 build.grade

這樣的頂級

0

內:

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