找不到参数api()的方法[目录'libs'] [英] Could not find method api() for arguments [directory 'libs']

查看:118
本文介绍了找不到参数api()的方法[目录'libs']的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打开文件

这是我的gradle文件:

This is my gradle file:

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.1"
        defaultConfig {
            applicationId "com.landdrops.cricketfantacy.androidbottom"
            minSdkVersion 21
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.android.support:appcompat-v7:27.0.1'
        implementation 'com.android.support:design:27.0.1'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test.runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
    }

我得到

错误:(23,0)在org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler类型的对象上找不到参数[目录'libs']的方法实现(). 打开文件

Error:(23, 0) Could not find method implementation() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Open File

推荐答案

我能够通过将大多数依赖关系更新为当前版本来纠正此错误(不确定是否必要,以及最新版本是否与另一个组件的依赖关系发生冲突) ,我还原了一个发行版,并消除了不匹配的情况.这时,我将27.1.0用于appCompat,design(我将27.0.3用于构建工具)

I was able to correct this error by updating most dependencies to current version (not sure that necessary, and when the most current version conflicted with a dependency of another component, I reverted one release back and it cleared up the mismatch. At this time, I am using 27.1.0 for appCompat, design. (I use 27.0.3 for build tools tho)

将包装程序升级到4.4版(实际上是提示我在加载过时的项目并更新插件时执行此操作)

Gradle wrapper to version 4.4 (this was actually prompted for me to do when loading an outdated project and updating the plugin)

调整后的项目build.gradle可以使用: classpath'com.android.tools.build:gradle:3.1.1'

Adjusted project build.gradle to use: classpath 'com.android.tools.build:gradle:3.1.1'

这篇关于找不到参数api()的方法[目录'libs']的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆