问题
I want to add a lib in android studio but it is not working. Here is a screenshot
I also tried to add a dependency in the gradle.build but that also does not work. Maybe it is because I am behind a proxy ?
回答1:
You are using the wrong build.gradle
file.
You can't use compile
in the top-level file.
Use the module/build.gradle
.
<PROJECT_ROOT>\app\build.gradle
is specific for app module.
<PROJECT_ROOT>\build.gradle
is a "Top-level build file" where you can add configuration options common to all sub-projects/modules.
Also you should include the libraries in the dependencies
block, not inside the buildscript
block.
Top level file example:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
In the app\build.gradle
you define only the properties for the module:
apply plugin: 'com.android.application'
android {
compileSdkVersion ...
buildToolsVersion ...
}
dependencies {
//..... HERE !
}
来源:https://stackoverflow.com/questions/46049022/could-not-find-method-compile