Dec 8, 2021

[memo] Could not find method compile() for arguments gradle

 I got the following error when I build my project.

> Could not find method compile() for arguments [org.slf4j:slf4j-api:1.7.24] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.


Here is a part of build.gradle

compile 'org.slf4j:slf4j-api:1.7.24'
compile 'org.slf4j:slf4j-simple:1.7.24'

I found the anwer https://stackoverflow.com/questions/23796404/could-not-find-method-compile-for-arguments-gradle.

From gradle 7.0 compile, runtime, testCompile, testRuntime are changed to implementation, runtimeOnly, testImplementation, testRuntimeOnly.

After I changed to implementation, my project is built successfully.

implementation 'org.slf4j:slf4j-api:1.7.24'
implementation 'org.slf4j:slf4j-simple:1.7.24'