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
            > Could not get resource ''.
               > Could not GET ''.
                  > 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 ""}
        maven { url '' }

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

Read More: