简体   繁体   中英

Android Studio latest version could not find method compile for arguments directory libs

I have pasted my build.gradle codes in this question, please suggest what to do.

Error message:

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

Configuration:

apply plugin: 'com.android.application'

ext {

    supportVersion='27.1.1'
}

android {

   compileSdkVersion 28

   defaultConfig {

       applicationId "com.eassycars.www.dlservices"

       minSdkVersion 17

       targetSdkVersion 28

       versionCode 1

       versionName "1.0"

       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

   }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildscript {
        repositories {
            jcenter()
        }
        configure(':app') {
        dependencies {
            classpath 'com.android.tools.build.gradle:4.8.1'
            compile fileTree(include: ['*.jar'], dir: 'libs')
            compile
            testCompile 'junit:junit:4.12'
            // google & support
            implementation "com.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler :$supportVersion"
            implementation "com.android.support:appcompat-v7:$supportVersion"
            implementation "com.android.support:cardview-v7:$supportVersion"
            implementation "com.android.support:recyclerview-v7:$supportVersion"
            implementation "com.android.support:design:$supportVersion"
            implementation "com.android.support:palette-v7:$supportVersion"
            implementation "com.android.support:customtabs:$supportVersion"
            implementation "com.android.support:support-v4:$supportVersion"
            implementation 'com.google.android.exoplayer:exoplayer:r2.0.4'
            // utils
            implementation 'com.github.bumptech.glide:glide:4.0.0'
            annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
            implementation 'com.koushikdutta.ion:ion:2.1.7'
            implementation 'com.github.Commit451:bypasses:1.0.4'
            implementation 'com.jakewharton:butterknife:8.8.0'
            annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0'
            implementation 'com.drewnoakes:metadata-extractor:2.9.1'
            implementation 'com.orhanobut:hawk:2.0.1'
            classpath 'com.google.gms:google-services:3.1.1'
            compile 'com.android.support:support-annotations:27.1.1'
        }}
    }
}

first of all you got a "compile" statement under "compile fileTree" with empty library. second change "compile fileTree" to "implementation fileTree"

Go to your project's build.gradle and check it's version under dependencies.

check project's build.gradle version

If you're using a version of Gradle lower than 4.1 then use this

allprojects {
    repositories {
         maven {
             url 'https://maven.google.com'
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM