android - 无法在对象上找到参数 [目录 'libs'] 的方法 compile()

标签 android gradle android-gradle-plugin

我尝试获取 GetHttpResponse,这是下面的代码。我已尝试重新同步项目,但无济于事。

Full error : Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

   configure(':app') {
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.2'
            compile fileTree(dir: 'libs', include: ['*.jar'])
            testCompile 'junit:junit:4.12'
            compile 'com.android.support:appcompat-v7:23.0.1'
            compile 'com.android.support:design:23.0.1'
            compile 'org.apache.httpcomponents:httpcore:4.4.1'
            compile 'org.apache.httpcomponents:httpclient:4.5'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

这是我的gradle文件

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "itp361.nyp"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'
    }

这是我的 gradle 应用程序文件。 我搜索了许多不同的问题并应用了它,但它仍然提示我错误。我还添加了可执行 jar 'org.arpache.http.leagcy' 到 C:\Users\user\Downloads\NYP\NYP\app\libs

最佳答案

阅读笔记。

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

你在项目 build.gradle 中。您必须将依赖项放入模块 build.gradle 中。这是您发布的第二个 fragment 。

关于android - 无法在对象上找到参数 [目录 'libs'] 的方法 compile(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44886189/

相关文章:

android - 如何获取读取外部存储权限?

android - 如何开发Android应用程序?

gradle - Jenkins jacoco插件-Java8仪表板报告已消失

Gradle:获取依赖项和许可证列表

android - Android Studio 中build.gradle 是如何自动改变的?

android - 从/tmp/gradle7963227675482339513.bin 中的二进制存储读取数据时出现问题(存在 : true)

android - Eclipse Logcat 未获取当前过滤器的更新 (Android)

android - 如何在android中播放在线广播

android - AsyncTask - 如何从 OnPostExecute 访问 GUI 元素

spring boot 1.0升级到2.0时java测试编译错误:'bad signature ¾4s9'