使用jenkins编译apk报错问题解决

之前项目可以正常在jenkins上构建,今天突然发现构建出错,问题如下:

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插件版本4.1.2,gradle版本6.5

该问题的解决办法如下:

1、找到moudle的build.gralle文件

将 testImplementation 'junit:junit:4.+'改为testImplementation 'junit:junit:4.12'

2、在jenkins服务器使用的gradle编译文件找到如下地方,修改为以下信息

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

然后重新使用jenkins构建,即可正常完成apk的构建了。

你可能感兴趣的:(Android,jenkins,maven)