Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.12}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

已回答

Steps to reproduce:
1. Create a new project 

2. Choose gradle 

3. Under additional libraries and framework I only choose "Java"

Now paste this line

" testCompile group: 'junit', name: 'junit', version: '4.12'"

in "build.gradle" and build.

I now ge the error:

Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.12}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

 

Gradle is sat to use Java openjdk 16.

How do I resolve this error?

1

Hello,

Most probably it is a compatibility issue with Gradle and OpenJDK 16. Please check if the problem reproduces if you build the project from the command line outside of IntelliJ.

Try using a different JDK version.

-1

It still doesn't work.

0

Please check Gradle version used in the project.

compile and testCompile configurations are removed in Gradle 7+. You can use implementation and testImplementation instead.

15

Hi there i am using android studio 2.3.2 and i am having and problem with the same and same problem. Gradle sync failed: Could not find method implementation() for arguments [com.android.support:appcompat-v7:34.+]

0

Natnaelmesfin55  Could you elaborate on the Android Studio version? Android Studio 2.3 is considered legacy at this point.

Also, could you please let me know the version if Gradle your Project is using and how/where the dependency is declared in your Project?

Note that support library packages appear to have been deprecated according to the Android documentation.

0

请先登录再写评论。