gradle "apply plugin" 放在哪里?
gradle where exactly to put "apply plugin"?
我正在尝试使用本教程在我的应用程序中添加 Google 分析:
https://developers.google.com/analytics/devguides/collection/android/v4/
但我一直纠结于问题,该行的确切位置:
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()
}
}
但这是错误的。请问应用插件具体放在哪里?
感谢您的帮助。
应该在对象内部
allprojects
在应用程序之上 build.grade
像这样:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
在android studio中你有这样的结构:
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'
}
我正在尝试使用本教程在我的应用程序中添加 Google 分析:
https://developers.google.com/analytics/devguides/collection/android/v4/
但我一直纠结于问题,该行的确切位置:
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()
}
}
但这是错误的。请问应用插件具体放在哪里?
感谢您的帮助。
应该在对象内部
allprojects
在应用程序之上 build.grade
像这样:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
在android studio中你有这样的结构:
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'
}