Using Jenkins to compile APK Error [How to Solve]

In the past, the project could be built on Jenkins normally. Today, it is suddenly found that the construction is wrong. The problems are as follows:

Could not determine the dependencies of task ':lint'.
> Could not resolve all artifacts for configuration ':releaseUnitTestCompileClasspath'.
   > Could not resolve junit:junit:4.+.
     Required by:
         project :
      > Failed to list versions for junit:junit.
         > Unable to load Maven meta-data from http://jcenter.bintray.com/junit/junit/maven-metadata.xml.
            > Could not get resource 'http://jcenter.bintray.com/junit/junit/maven-metadata.xml'.
               > Could not GET 'https://jcenter.bintray.com/junit/junit/maven-metadata.xml'.
                  > org.apache.http.client.ClientProtocolException (no error message)
      > Skipped due to earlier error

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Gradle plug-in version 4.1.2, gradle version 6.5

The solution to this problem is as follows:

1. Find the build.gralle file of moudle.

Modify testImplementation 'junit:junit:4.+' to testImplementation 'junit:junit:4.12'

2. Find the following places in the gradle compilation file used by Jenkins server and modify it to the following information

allprojects {
    repositories {
        jcenter { url "http://jcenter.bintray.com/"}
        google()
        maven { url 'http://repo1.maven.org/maven2' }
    }
}

Then use Jenkins to build again, and the APK can be built normally.

Read More: