找不到方法compile()
问题描述:
答
您使用了错误build.gradle
文件。
您不能在顶层文件中使用compile
。使用module/build.gradle
。
<PROJECT_ROOT>\app\build.gradle
是针对应用模块的具体。
<PROJECT_ROOT>\build.gradle
是“顶层构建文件”您可以在其中添加对所有子项目/模块通用的配置选项。
此外,您应该将库包含在dependencies
块中,而不是在buildscript
块中。
*文件例如:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
在app\build.gradle
您的模块只定义属性:
apply plugin: 'com.android.application'
android {
compileSdkVersion ...
buildToolsVersion ...
}
dependencies {
//..... HERE !
}
你看了'NOTE',即位于第14行? – DeKaNszn