我正在尝试将OkHttp
添加到我的项目中,我同时下载OkHttp
和Okio
库并将其添加到libs
目录。
比我添加编译方法:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我尝试构建应用程序并收到此错误:
Error:(27, 1) A problem occurred evaluating root project 'APP'.
> Could not find method compile() for arguments [com.squareup.okhttp3:okhttp:3.4.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
知道可能是什么问题吗?我正在使用Android Studio om mac OS
答案 0 :(得分:2)
删除根gradle的这一行:
directionsArray += [(locationArray[i].textField?.text,
locationArray[i+1].textField?.text, routes[i])]
并将此添加到依赖项的应用程序模块build.gradle
答案 1 :(得分:1)
我们的项目中基本上有两个build.gradle文件。
这里的问题是你正在编译okHttp
顶级gradle文件中的compile 'com.squareup.okhttp3:okhttp:3.4.1'
尝试将其放在Module level gradle中。此外,如果您使用gradle导入库,则不必将其显式添加到lib文件夹中