问题描述
打开文件
这是我的 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 类型的对象上找到参数 [directory 'libs'] 的方法 implementation().打开文件
推荐答案
我能够通过将大多数依赖项更新到当前版本来纠正此错误(不确定是否有必要,并且当最新版本与另一个组件的依赖项发生冲突时, 我恢复了一个版本,它清除了不匹配.此时,我使用 27.1.0 进行 appCompat 设计.(我使用 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)
Gradle wrapper 到 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 使用:类路径 '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']的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!