Home > Blockchain >  Couldn't find compile() for arguments [directory 'libs'] on object of type org.gradle
Couldn't find compile() for arguments [directory 'libs'] on object of type org.gradle

Time:10-27

My build.gradle

    apply plugin: 'com.android.application'

android {
    signingConfigs {
    }
    compileSdkVersion 30
    buildToolsVersion '30.0.2'
    defaultConfig {
        applicationId "com.rock08.android.demoapp"
        minSdkVersion 22
        targetSdkVersion 25
        versionCode 2
        versionName "0.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:leanback-v17:25.4.0'
    compile 'com.android.support:recyclerview-v7:25.4.0'
    compile 'com.android.support:preference-v7:25.4.0'
    compile 'com.android.support:preference-v14:25.4.0'
    compile 'com.android.support:preference-leanback-v17:25.4.0'
    compile 'com.android.support:appcompat-v7:25.4.0'
    compile 'com.android.support:palette-v7:25.4.0'
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

The gradle build is getting failed.

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

CodePudding user response:

This is expected with Gradle 7.2 since the compile and testCompile configurations have been removed.

You must replace compile with implementation and testCompile with testImplementation

  • Related