Tag Archives: Failed to resolve: junit:junit:4.12

Failed to resolve: junit:junit:4.12 [How to Solve]

Failed to resolve: junit:junit : 4.12 solutions

:

causes:

the code in JUnit library is referenced in the project, but there is no related JUnit dependent library yet

solutions:

method 1: add related dependency libraries; Method 2: delete references related to JUnit

1. Add the following code to the build.gradle of the module of the project 2

repositories {
    maven { url 'http://repo1.maven.org/maven2' }
}

2. Delete the reference to JUnit in build.gradle of the module of the project 2

Delete the following sentence

testCompile 'junit:junit:4.12'

but with the second method, there will be a problem after deletion. In SRC java code, errors will be reported where JUnit library related code is used. At this time, we have to delete these references to JUnit. If you don’t need to do unit testing, you can delete JUnit related things, but it’s better to use the first method, Keep the function of unit testing