android - Android 工作室在项目“:app”上找不到参数 [目录“libs”] 的方法 implementation()
问题描述
我正在尝试加载一个APP
. 但我收到一个错误
构建文件 'F:\Android Studio Projects\SalesManagement-Agent\app\build.gradle' 行:30
评估项目 ':app' 时出现问题。
在项目“:app”上找不到参数 [目录“libs”] 的方法 implementation()。
摇篮
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}}
和
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.anik.agent"
minSdkVersion 14
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'org.apache.httpcomponents:httpcore:4.4.10'
implementation('org.apache.httpcomponents:httpmime:4.5.6') {
exclude module: 'httpclient'
}
}
任何帮助将不胜感激。
解决方案
尝试构建工具30.0.3
并确保 Gradle 插件是最新的。当时关键字implementation
不存在并被调用compile
(已弃用并将在 Gradle 7 中删除)。