20

打开文件

这是我的毕业文件:

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()。打开文件

4

2 回答 2

57

对于我的 Java 库项目,我需要使用java-library插件而不是java

- apply plugin: 'java'
+ apply plugin: 'java-library'
于 2020-01-13T04:22:01.017 回答
1

我能够通过将大多数依赖项更新到当前版本来纠正此错误(不确定是否有必要,并且当最新版本与另一个组件的依赖项冲突时,我将一个版本恢复回来并清除了不匹配。此时,我将 27.1.0 用于 appCompat,设计。(我使用 27.0.3 作为构建工具)

Gradle wrapper 到 4.4 版(这实际上是在加载过时的项目和更新插件时提示我做的)

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

于 2018-04-18T18:53:34.797 回答