blurry
blurry

Reputation: 13

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

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.

Upvotes: 1

Views: 4161

Answers (2)

Maryam Maleki
Maryam Maleki

Reputation: 21

My solution is. jar file Directory is /WEB-INF/lib/MyJarFile.jar :)

flatDir {
  name 'lib'
  dirs "$rootProject.projectDir/lib"
}

dependencies {
  classpath fileTree(dir: 'lib', include: 'MyJarFile.jar')
}

Upvotes: 1

Thomas Kläger
Thomas Kläger

Reputation: 21435

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

Upvotes: 5

Related Questions